mybatis配置文件mapper.xml中trim标签的用法

在mapper.xml中对statement的定义,可以用<trim>来填充和隐藏sql语句。

<!--修改user的statement-->
<update id="updateUser" parameterType="user">
update user 
<trim prefix="set" suffixOverrides=",">
<if test="userPassword!=null">
user_password=#{userPassword},
</if>
<if test="userType!=null">
user_type=#{userType},
</if>
</trim>
where user_id=#{iD}
</update>

标签:trim

属性:

1.prefix--》在trim标签定义的内容前填充对应内容

2.prefixOverrides--》在trim定义的中,隐藏头部对应的内容

3. suffix--》在trim标签定义的内容后填充内容

4.suffixOverrides--》在trim定义的中,隐藏尾部对应的内容

猜你喜欢

转载自www.cnblogs.com/zhihow/p/9815816.html