首页 > 其他 > 详细

mybatis入门截图三

时间:2017-09-04 10:28:09      阅读:254      评论:0      收藏:0      [点我收藏+]

技术分享

技术分享

技术分享

 

 技术分享

技术分享

 

 技术分享

-----------------------------------------------

技术分享

    <!-- 用户信息的综合查询 -->
    <select id="userlist" parameterType="org.mybatis.po.UserQueryVo" resultType="org.mybatis.po.UserCustom">
        <!-- 原来的sql -->
        <!-- select *from user where user.sex=#{userCustom.sex} and user.username like ‘%${userCustom.username}%‘ -->
        <!-- 动态sql -->
        select *from user 
        <where>
            <if test="userCustom!=null">
                <if test="userCustom.sex!=null and userCustom.sex!=‘‘">
                    and user.sex=#{userCustom.sex}
                </if>
                <if test="userCustom.username!=null and userCustom.username!=‘‘">
                    and user.username=#{userCustom.username}
                </if>
            </if>
        </where>
    </select>

这样在传入参数时,传递null  也不会报错。

 

mybatis入门截图三

原文:http://www.cnblogs.com/Joke-Jay/p/7471318.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!