现在的写法(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)的第三行,以及“,”(逗号的位置)。