现在的写法(A)

 1     <update id="update" parameterType="ruleItem.Bean">
 2         update t_rule_item
 3         <!-- set id=#{id} --> 
 4         <set>
 5             <if test="ruleId!=null and ruleId != ''">ruleId=#{ruleId},</if>
 6             <if test="fieldName!=null and fieldName != ''">fieldName=#{fieldName},</if>
 7             <if test="comment!=null and comment != ''">comment=#{comment},</if>        
 8         </set>
 9         where id=#{id}
10     </update>

 原来的写法(B)

 1     <update id="update" parameterType="ruleItem.Bean">
 2         update t_rule_item
 3         set id=#{id}
 4         
 5             <if test="ruleId!=null and ruleId != ''">,ruleId=#{ruleId}</if>
 6             <if test="fieldName!=null and fieldName != ''">,fieldName=#{fieldName}</if>
 7             <if test="comment!=null and comment != ''">,comment=#{comment}</if>        
 8         
 9         where id=#{id}
10     </update>

区别:(B)的第三行,以及“,”(逗号的位置)。

MyBatis 中的 set 元素用法(MyBatis 3.1.1)

 

相关文章:

  • 2022-12-23
  • 2021-05-17
  • 2021-11-28
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2021-11-08
  • 2021-09-09
猜你喜欢
  • 2021-04-28
  • 2021-11-19
  • 2021-12-01
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案