springboot的sql动态映射xml的小注意事项

 1 <mapper namespace="com.lian.mapper.IncomeMapper">
 2     <update id="update">
 3         update income
 4         <set>
 5             <if test="username!=null and username!=''">
 6                 username=#{username},
 7             </if>
 8             <if test="name!=null and name!=''">
 9                 name=#{name},
10             </if>
11             <if test="classify!=null and classify!=''">
12                 classify=#{classify},
13             </if>
14             <if test="money!=null and money!='' ">
15                 money=#{money},
16             </if>
17             <if test="addtime!=null and addtime!=''">
18                 addtime=#{addtime},
19             </if>
20             <if test="comment!=null and comment!=''">
21                 comment=#{comment},
22             </if>
23         </set>
24         where id=#{id}
25     </update>

21行的comment,也就是where语句前面的最后一个字段,comment=#{comment}这行代码的后边一定要带上逗号,否则回修改失败

posted @ 2024-11-27 09:11  连师傅只会helloword  阅读(17)  评论(0)    收藏  举报