美文网首页
插入语句的xml小结

插入语句的xml小结

作者: 轰轰_9ccd | 来源:发表于2019-03-18 08:49 被阅读0次

    <update id="updateByPrimaryKey" parameterType="com.glxcn.mybatis.model.TSysUser">

      update t_sys_user

    <trim prefix="set" suffixOverrides=",">

        <if test="username!=null">

          username = #{username,jdbcType=VARCHAR},

        <if test="password!=null and password!=''">

          password = #{password,jdbcType=VARCHAR},

        <if test="createTime!=null">

          create_time = #{createTime,jdbcType=TIMESTAMP},

        <if test="salt!=null">

          salt = #{salt,jdbcType=VARCHAR},

        <if test="loginTime!=null">

          login_time = #{loginTime,jdbcType=TIMESTAMP},

        <if test="logoutTime!=null">

          logout_time = #{logoutTime,jdbcType=TIMESTAMP},

        <if test="lastIp!=null">

          last_ip = #{lastIp,jdbcType=VARCHAR},

        <if test="status!=null">

          status = #{status,jdbcType=BIT},

        <if test="des!=null">

          des = #{des,jdbcType=VARCHAR},

        <if test="avatar!=null">

          avatar = #{avatar,jdbcType=VARCHAR},

        <if test="audit!=null">

          audit = #{audit,jdbcType=VARCHAR},

        <if test="ip!=null">

          ip = #{ip,jdbcType=VARCHAR},

        <if test="realname!=null">

          realname = #{realname,jdbcType=VARCHAR},

      where user_id = #{userId,jdbcType=INTEGER}

    </update>

    可以用 此方法进行判断

        


    在注解上useGeneratedKeys="true" keyProperty="userId"加这个默认返回id;keyProperty为主键名称

    相关文章

      网友评论

          本文标题:插入语句的xml小结

          本文链接:https://www.haomeiwen.com/subject/commmqtx.html