mybatisのdeleteとudate文

7209 ワード

mybatisのdelete
<delete id="deleteById">
    delete from sys_user where id = #{id}
delete>
  • コメント@Delete
  • @Delete({"delete from sys_role where id = #{id}"})
    
    void detele1(Long id);
    
    mybatisのudate
    <update id="updateById" parameterType="SysUser">
    update sys_user
      <set>
       <if test="userName !=null and userName!=''">
        user_name = #{userName},
       if>
       <if test="userPassword !=null and userPassword !=''">
        user_password = #{userPassword},
       if>
       <if test="userEmail !=null and userEmail !=''">
        user_email = #{userEmail},
       if>
       <if test="userInfo !=null and userInfo !=''">
        user_info = #{userInfo},
       if>
       <if test="headImg !=null">
        head_img = #{headImg},
       if>
       <if test="createTime !=null">
        create_time = #{createTime},
       if>
      set>
      <where>
       id = #{id}
      where>
    update>
    
  • コメント@udate
  • 
    @Update({ "update sys_role set role_name=#{roleName},enabled = #{enabled},"
           + "create_by=#{createBy},create_time=#{createTime,jdbcType=TIMESTAMP} " 
           + "where id=#{id}"})
    void update1(SysRole sysRole);