<!-- 获取用户 sql-->
<!-- trim prefixOverrides 标签预处理, if(null != id and ''!= id) 则 添加搜索条件 and id=#{id} -->
<select id="getUserInfo" parameterType="com.course.usertest.model.User" resultType="com.course.usertest.model.User">
select * from user
<trim prefix="where" prefixOverrides="and">
<if test="null != id and ''!= id">
and id = #{id}
</if>
<if test="null != userName and '' != useName">
and userName=#{userName}
</if>
<if test="null != password and '' != password">
and password=#{password}
</if>
<if test="null != age and '' != age">
and age=#{age}
</if>
<if test="null != sex and '' != sex">
and sex=#{sex}
</if>
<if test="null != permission and '' != permission">
and permission=#{permission}
</if>
<if test="null != isDelete and '' != isDelete">
and isDelete=#{isDelete}
</if>
</trim>
</select>
<!-- 更新/ 删除用户信息-->
<!-- trim suffixOverrides 标签尾处理 -->
<update id="updateUserInfo" parameterType="com.course.usertest.model.User">
update user
<trim prefix="SET" suffixOverrides=",">
<if test="null != userName and '' != useName">
and userName=#{userName},
</if>
<if test="null != password and '' != password">
and password=#{password},
</if>
<if test="null != age and '' != age">
and age=#{age},
</if>
<if test="null != sex and '' != sex">
and sex=#{sex},
</if>
<if test="null != permission and '' != permission">
and permission=#{permission},
</if>
<if test="null != isDelete and '' != isDelete">
and isDelete=#{isDelete},
</if>
</trim>
</update>
mapperSQL中的预处理及尾处理
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 【蝴蝶效应】 蝴蝶效应:上个世纪70年代,美国一个名叫洛伦兹的气象学家在解释空气系统理论时说,亚马逊雨林一只蝴蝶...
- 1. 讨论近期的一个热点。 郭女士是某县城的老师,女儿聪明伶俐,人见人爱,学习成绩一直名列前茅。 当收到女儿清华大...