例子一

查询条件dto

public class queryCondition
{
 private String[] stuIds;
 private String name;
}

查询sqlMap

<select id="selectStu" parameterClass="cn.xy.queryCondition" resultClass="cn.xy.Student">
 select id,name from student
 <dynamic prepend="where">
  <isNotNull property="stuIds" prepend="and">
   <iterate property="stuIds" open="id in (" close=")" conjunction=",">
    #stuIds[]#
   </iterate>
  </isNotNull>
  <isNotNull property="name" prepend="and">
   name like '%$name$%'
  </isNotNull>
 </dynamic>
</select>

在查询条件中有一个数组stuIds,在动态标签中进行遍历,看每一个student的id是否在该数组中。

发出的语句 select id,name from student where  id in ( ? , ?) ...

例子二

查询条件dto

public class queryCondition
{
 private List<Student> lst;
 private String name;
}

查询sqlMap

<select id="selectStu" parameterClass="cn.xy.queryCondition" resultClass="cn.xy.Student">
 select id,name from student
 <dynamic prepend="where">
  <isNotNull property="lst" prepend="and">
   <iterate property="lst" open=" (" close=")" conjunction="or">
    id = #lst[].id#
   </iterate>
  </isNotNull>
  <isNotNull property="name" prepend="and">
   name like '%$name$%'
  </isNotNull>
 </dynamic>
</select>

发出的语句 select id,name from student where  (id = ?   or   id = ?)...

最新文章

  1. 200行代码搞定炸金花游戏(PHP版)
  2. NetFPGA
  3. Java简单类——一对多映射(省、市)
  4. 一个最简html5文档来说明html5的新特性和写法
  5. InnoDB Plugin文件格式(概述)
  6. 异步JS:$.Deferred的使用
  7. Android 自学之对话框
  8. Jersey(1.19.1) - Building Responses
  9. Oralce11 客户端的安装和 PlSql Developer 的配置
  10. java小提示:标示符常见命名规则、常用ASCII
  11. 织梦sitemap模板获取文章列表
  12. 扩展jquery easyui datagrid编辑单元格
  13. scrapy_redis实现爬虫
  14. 20)django-session使用
  15. [LeetCode] Bomb Enemy 炸弹人
  16. Ubuntu上Qt之简单图片浏览器
  17. kubernetes1.9管中窥豹-CRD概念、使用场景及实例
  18. uWSGI的stats注释,送给需要的人,欢迎指正
  19. /proc/meminfo详解
  20. Linux防火墙配置学习记录

热门文章

  1. MySQL线上执行大事务或锁表操作
  2. 十天学会单片机Day1点亮数码管(数码管、外部中断、定时器中断)
  3. Python学习教程(learning Python)--3 Python分支结构和布尔逻辑
  4. C# Sql 触发器
  5. PagerAdapter的notifyDataSetChanged无效解决方法
  6. DB2物化表
  7. Base
  8. 修改linux端口范围 ip_local_port_range
  9. NET Core中使用Redis
  10. jta.properties transactions.properties Log already in use 解决方法