Mybatis中的update动态SQL语句 <trim></trim> 用法
时间:2017-09-25 21:39:47
收藏:0
阅读:2134
Mybatis Mapper中文件中
update时,需要set设置多个字段,有时逗号处理时,会报错误,所以会使用到<trim></trim>
使用trim就是为了删掉最后字段的“,”。
主要不用单独写SET了,因为set被包含在trim中了:
<update id="update" parameterType="com.entity.Entity"> <trim prefix="set" suffixOverrides=","> <if test="isPublish!=null"> is_publish = #{isPublish}, </if> </trim> WHERE id = #{id} </update>
原文:http://www.cnblogs.com/kaishi/p/7593852.html
评论(0)