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 = ?)...
ibatis中iterate的用法(conjunction="or" ",")的更多相关文章
- hibernate中get,load,list,iterate的用法及比较
首先,get和load都是查询单个对象,而list和iterate为批量查询 注意以下写法仅针对hibernate3的语法. 使用案例如下: // 1. get和load 的用法 Person p = ...
- ibatis配置xml文件中CDATA的用法
ibatis作为一种半自动化的OR Mapping工具,其灵活性日益体现出来,越来越多的人都倾向于在项目中使用.由于Sql中经常有与xml规范相冲突的字符对xml映射文件的合法性造成影响.许多人都知道 ...
- mybatis中foreach的用法(转)
foreach一共有三种类型,分别为List,[](array),Map三种. foreach属性 属性 描述 item 循环体中的具体对象.支持属性的点路径访问,如item.age,item.inf ...
- ibatis实现Iterate的使用
<iterate property="" /*可选, 从传入的参数集合中使用属性名去获取值, 这个必须是一个List类型, 否则会出现OutofRangeException, ...
- Ibatis中传List参数
Ibatis中用list传参数的方式. Java代码 select count(id) from `user` where id in #[]# and status=1 . <select ...
- ibatis的iterate使用
Iterate:这属性遍历整个集合,并为 List 集合中的元素重复元素体的内容. Iterate 的属性: prepend - 可被覆盖的 SQL 语句组成部分,添加在语句的前面(可选 ...
- IBATIS中‘$’与‘#’使用
IBATIS中关于iterate和‘$’与‘#’的应用 一个包含List元素的HashMap参数赋给sqlMap public int getCountById(String id, String ...
- ibatis中使用List作为传入参数的使用方法及 CDATA使用
ibatis中list做回参很简单,resultClass设为list中元素类型,dao层调用: (List)getSqlMapClientTemplate().queryForList(" ...
- ibatis实现Iterate的使用 (转)
<iterate property="" /*可选, 从传入的参数集合中使用属性名去获取值, 这个必须是一 ...
随机推荐
- C#之委托初步
传说中的东西,今天兴趣来了,就研究了研究,把大概什么是委托,如何使用委托稍微梳理了一下. 1.什么是委托 首先,Class(类)是对事物的抽象,例如,哺乳动物都是胎生,那么你可以定义一个哺乳动物的基类 ...
- hadoop-cdh with snappy
hadoop: 2.5.0-cdh5.3.6 snappy: 1.1.3 hadoop 2.*不需要hadoop-snappy.只要机器上安装好snappy, 直接编译就可以 编译命令: mvn cl ...
- linux 修改系统时间
首先进入/proc/sys/xen,执行以下命令 [root@test]#cd /proc/sys/xen[root@test]#echo 1 > independent_wallclock ...
- python批量导出导入MySQL用户的方法
这篇文章主要介绍了 数据库迁移(A -> B),需要把用户也迁移过去,而用户表(mysql.user)有上百个用户.有2种方法进行快速迁移: 1,在同版本的条件下,直接备份A服务器的mysql数 ...
- Android Studio添加aar包依赖
1.将aar包考入需要依赖的模块的libs目录下 2.在需要依赖的模块的build.gradle中添加如下内容: dependencies { compile(name:'aar包名不带扩展名', e ...
- Linux环境PostgreSQL源码编译安装
Linux环境PostgreSQL源码编译安装 Linux版本: Red Hat 6.4 PostgreSQL版本: postgresql-9.3.2.tar.gz 数据存放目录: /var/post ...
- wpa_supplicant软件架构分析
wpa_supplicant软件架构分析 1. 启动命令 wpa supplicant 在启动时,启动命令可以带有很多参数,目前我们的启动命令如下: wpa_supplicant /system/bi ...
- iOS下日期的处理
NSDate存储的是世界标准时(UTC),输出时需要根据时区转换为本地时间 Dates NSDate类提供了创建date,比较date以及计算两个date之间间隔的功能.Date对象是 ...
- 【转载】FPGA静态时序分析——IO口时序
转自:http://www.cnblogs.com/linjie-swust/archive/2012/03/01/FPGA.html 1.1 概述 在高速系统中FPGA时序约束不止包括内部时钟约束 ...
- 出色的 JavaScript API 设计秘诀
设计是一个很普遍的概念,一般是可以理解为为即将做的某件事先形成一个计划或框架. (牛津英语词典)中,设计是一种将艺术,体系,硬件或者更多的东西编织到一块的主线.软件设计,特别是作为软件设计的次类的AP ...