ibatis中iterate的用法(conjunction="or" ",")
例子一
查询条件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 = ?)...
最新文章
- 200行代码搞定炸金花游戏(PHP版)
- NetFPGA
- Java简单类——一对多映射(省、市)
- 一个最简html5文档来说明html5的新特性和写法
- InnoDB Plugin文件格式(概述)
- 异步JS:$.Deferred的使用
- Android 自学之对话框
- Jersey(1.19.1) - Building Responses
- Oralce11 客户端的安装和 PlSql Developer 的配置
- java小提示:标示符常见命名规则、常用ASCII
- 织梦sitemap模板获取文章列表
- 扩展jquery easyui datagrid编辑单元格
- scrapy_redis实现爬虫
- 20)django-session使用
- [LeetCode] Bomb Enemy 炸弹人
- Ubuntu上Qt之简单图片浏览器
- kubernetes1.9管中窥豹-CRD概念、使用场景及实例
- uWSGI的stats注释,送给需要的人,欢迎指正
- /proc/meminfo详解
- Linux防火墙配置学习记录
热门文章
- MySQL线上执行大事务或锁表操作
- 十天学会单片机Day1点亮数码管(数码管、外部中断、定时器中断)
- Python学习教程(learning Python)--3 Python分支结构和布尔逻辑
- C# Sql 触发器
- PagerAdapter的notifyDataSetChanged无效解决方法
- DB2物化表
- Base
- 修改linux端口范围 ip_local_port_range
- NET Core中使用Redis
- jta.properties transactions.properties Log already in use 解决方法