mybatis update
需求:更新字段作为参数,未更新字段不传入
解决办法
<update id="updateUser" parameterType="com.test.entity.User">
update BS_USER
<trim prefix="set" suffixOverrides=",">
<if test="ACCOUNT != null">ACCOUNT=#{ACCOUNT},</if>
<if test="NAME != null">NAME=#{NAME},</if>
<if test="PROV != null">PROV=#{PROV},</if>
<if test="FAILURE_TIME != null">FAILURE_TIME=#{FAILURE_TIME},</if>
</trim>
where USERID=#{USERID}
</update>
将set标签换成<trim prefix="set"></tirm>
标签中suffixOverrides=","
的意思是最后一个去掉逗号