将jdbc改写为mybatis时,传入的条件为list使用到的标签是<where> 、<choose>、<when>、<if>、<foreach>因为判断list集合时判断条件不全,导致sql执行错误,下面是正确的判断条件

<where>
  <choose>
    <when test="unitList != null and ! unitList.isEmpty() and unitList.size() > 0">
    (tab2.id IN
      <foreach collection="unitList" item="item" index="index"
      open="(" separator="," close=")">
      #{item}
      </foreach>
      AND tab1.`status` = #{deviceStatus})
    <if test="zoonList != null and ! zoonList.isEmpty() and zoonList.size() > 0">
      OR (tab2.leaderId IN
        <foreach collection="zoonList" item="item" index="index"
        open="(" separator="," close=")">
        #{item}
        </foreach>
      AND tab1.`status` = #{deviceStatus})
    </if>
  </when>
  <when test="zoonList != null and ! zoonList.isEmpty() and zoonList.size() > 0">
    tab2.leaderId IN
    <foreach collection="zoonList" item="item" index="index"
      open="(" separator="," close=")">
      #{item}
     </foreach>
    AND tab1.`status` = #{deviceStatus}
  </when>
  </choose>
</where>

最新文章

  1. HTML 事件(四) 模拟事件操作
  2. ASP.NET MVC之路由特性以及母版页呈现方式(十二)
  3. 转!java基础笔记
  4. [译]在Mac上运行ASP.NET 5
  5. VC++ 限制窗口的大小范围的方法
  6. JSP JSTL EL
  7. tomcat下jndi配置
  8. 创建xml时,设置xml编码问题
  9. Activti跳过中间节点的helloworld实例程序
  10. 使用sui实现的选择控件【性别、日期、省市级联】
  11. WPF学习之路初识
  12. 提交App到Apple Store(Xcode4)
  13. UML之轻松入门(2)-掌握Junit,让我们的开发更高效
  14. Css实现一个简单的幻灯片效果页面
  15. IntelliJ idea学习资源
  16. ajax跨域例子
  17. python入门-基础语法
  18. 1.5、CDH 搭建Hadoop在安装之前(定制安装解决方案)
  19. 日志审计系统、事件日志审计、syslog审计
  20. sublime text3 -- JavaScript Completions

热门文章

  1. jenkins git can&#39;t work ERROR: Timeout after 10 minutes ERROR: Error fetching remote repo &#39;origin&#39;
  2. element table 二次封装 父子组件传值 组件通信
  3. 51Nod 算法马拉松12 移数博弈
  4. double保留两位小数
  5. 文件上传中UUID的解读
  6. 2、Kafka架构
  7. 类自动调用to.string方法
  8. 力扣(LeetCode)605. 种花问题
  9. 版本控制 version control
  10. yum命令报错 yum update File &quot;/usr/bin/yum&quot;, line 30 except KeyboardInterrupt, e: --CentOS7.5