首页 > 其他分享 >mybatis 嵌套 if 判断

mybatis 嵌套 if 判断

时间:2022-11-30 19:12:01浏览次数:36  
标签:判断 like licNo licOrgCode 嵌套 creditCode orgCode mybatis concat

<select id="queryAdminLicenseDtoList" parameterType="map" resultType="com.zxwa.ntmss.dto.creditmanage.credictremark.AdminLicenseDto">
    SELECT
        b.*,s.orgName
    FROM
        base_credit_company_admin_license b
    LEFT JOIN sys_org s ON b.licOrgCode = s.orgCode
    <where>
        <if test="companyName != null and companyName != ''">
            and companyName like concat('%', #{companyName}, '%')
        </if>
        <if test="creditCode != null and creditCode != ''">
            and creditCode like concat('%', #{creditCode}, '%')
        </if>
        <if test="registrationCode != null and registrationCode != ''">
            and registrationCode like concat('%', #{registrationCode}, '%')
        </if>
        <if test="legalPerson != null and legalPerson != ''">
            and legalPerson like concat('%', #{legalPerson}, '%')
        </if>
        <if test="licNo != null and licNo != ''">
            and licNo like concat('%', #{licNo}, '%')
        </if>
        <if test="licName != null and licName != ''">
            and licName like concat('%', #{licName}, '%')
        </if>
        <if test="licId != null and licId != ''">
            and licId like concat('%', #{licId}, '%')
        </if>
        <if test="orgCode !=null and orgCode !=''">
            <if test="containSub == '1'.toString()">
                and b.licOrgCode like concat(#{orgCode},'%')
            </if>
            <if test="containSub == '0'.toString()">
                and b.licOrgCode = #{orgCode}
            </if>
        </if>
        <if test="validStart !=null and validStart !='' ">
            AND b.validFrom &gt;= #{validStart}
        </if>
        <if test="validEnd !=null and validEnd !='' ">
            AND b.validTo &lt; #{validEnd}
        </if>
    </where>
    ORDER BY b.validFrom DESC
    limit #{start}, #{pageNo}
</select>

 

标签:判断,like,licNo,licOrgCode,嵌套,creditCode,orgCode,mybatis,concat
From: https://www.cnblogs.com/JYB2021/p/16939481.html

相关文章

  • 一个简单的ssm案例之Mybatis框架搭建
    1、修改AccountDaopackagecom.cnstrong.dao;importcom.cnstrong.domain.Account;importorg.apache.ibatis.annotations.Insert;importorg.apache.ibatis.annotations.Se......
  • 一个简单的ssm案例之spring整合mybatis
    把生成的代理对象存到ioc容器中,service就可以拿到代理对象并注入,就可以调用dao中的方法。1、修改applicationContext.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxm......
  • 一个简单的ssm整合案例之spring整合mybatis配置事务
    1、修改applicationContext.xml为:<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.......
  • mybatis-续中续
    日志工厂如果数据库操作,出现了异常,需要记性排错,日志就是最好的助手!曾经:soutdebug现在:日志工厂SLF4JLOG4J(3.5.9起废弃)【掌握】LOG4J2【掌握】JDK_LOGGINGCO......
  • spring-mybatis
    对我来说,mybatis有几个主要核心模块吧。包括:插件(Plugin)、缓存、动态sql解析,这几个是比较难理解的部分。加载项目的时候会把mybatis里面的sql解析成一个个的MapperedStatem......
  • mybatis 连接 oracle使用concat关键字模糊查询
    oracle中不支持concat的三个参数的拼接,需要更正为SELECT*FROM"t_Dormitorys"where"RoomName"likeCONCAT(CONCAT('%','1'),'%')......
  • 关于mybatis中基本类型 条件判断问题
    Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取Integer.xxx。Integer对象没有xxx属性。如果不解析参数,mybatis自动识别传入的参数,不会报错。解决办法1.修改selec......
  • mybatis 中 if-test 判断
    之前用都是判断参数是否为空之类的,今天要判断等于一个字符,直接写等于号反而会没有执行直接跳过,后来上网查阅了资料才知道原因是:mybatis是用OGNL表达式来解析的,在OGNL的表......
  • Mybatis源码分析(十五) - 缓存技术
    MyBatis包含一个非常强大的查询缓存特性,使用缓存可以使应用更快地获取数据,避免频繁的数据库交互 缓存查询图: 一级缓存(也叫应用缓存)一级缓存默认会启用,想要关闭一级缓存......
  • Mybatis源码分析(十三) - 关联查询之多对多
    我的理解是,多对多其实就是两个一对多。嵌套结果:示例代码:<selectid="selectUserRole"resultMap="userRoleInfo">selecta.id,a.user_name,a.real......