Iterate:这属性遍历整个集合,并为 List 集合中的元素重复元素体的内容。 
Iterate 的属性: 
      prepend  - 可被覆盖的 SQL 语句组成部分,添加在语句的前面(可选) 
      property  - 类型为 java.util.List 的用于遍历的元素(必选) 
      open  -  整个遍历内容体开始的字符串,用于定义括号(可选) 
      close  -整个遍历内容体结束的字符串,用于定义括号(可选) 
      conjunction -  每次遍历内容之间的字符串,用于定义 AND 或 OR(可选) 
      遍历类型为 java.util.List的元素。

例子: 
<iterate prepend=”AND” property=”userNameList” 
open=”(” close=”)” conjunction=”OR”> 
username=#userNameList[]# 
</iterate>

ibatis中如何配置in语句,需要迭代,不能直接用string的写法
<select id="sql_test" parameterclass="myPramBean" resultclass="myResult">
select *from tablewhere name in 
<iterate property="ids" conjunction="," close=")" open="(" /> 
#value[]# 
</iterate>
and code=#code#
</select>
myPramBean
{
private String code;
private List ids;
...
}

eg:
<delete id="member.batchDelete" parameterClass="java.util.List">
      DELETE FROM member where id IN
      <iterate conjunction="," open="(" close=")" >
          #value[]# 
      </iterate>
</delete>

注意:使用<iterate>时,在List元素名后面包括方括号[]非常重要,方括号[]将
对象标记为List,以防解析器简单地将List输出成String。

posted on 2010-02-02 15:49 飞熊 阅读(20034) 评论(3)  编辑  收藏 所属分类: Ibatis

评论

# re: ibatis的iterate使用 2011-10-06 01:10 wiky

ibatis中如何配置in语句,需要迭代,不能直接用string的写法
<select id="sql_test" parameterclass="myPramBean" resultclass="myResult">
select *from tablewhere name in 
<iterate property="ids" conjunction="," close=")" open="(" /> 
#value[]# 
</iterate>
and code=#code#
</select>

#value[]# 要改成#ids[]# 才行  回复  更多评论

# re: ibatis的iterate使用[未登录] 2013-08-22 13:36 呵呵

第三种:in后面的数据确定,使用string传入 
<select id="GetEmailList_Test2" parameterClass="TestIn" resultClass="EmailInfo_"> 
select * 
from MailInfo with (nolock) 
where ID in 
($StrValue$) 
</select>

ibatis的iterate使用的更多相关文章

  1. ibatis实现Iterate的使用

    <iterate property="" /*可选, 从传入的参数集合中使用属性名去获取值, 这个必须是一个List类型, 否则会出现OutofRangeException, ...

  2. ibatis实现Iterate的使用 (转)

    <iterate         property="" /*可选,              从传入的参数集合中使用属性名去获取值,              这个必须是一 ...

  3. ibatis使用iterate实现批量插入insert正确写法

    由于想批量入库提升效率,最近实现了ibatis的批量插入,结果一直报错 :StringIndexOutOfBoundsException ,原来是value中的格式不正确. 本人邮箱:techqu@1 ...

  4. ibatis中iterate的用法(conjunction="or" ",")

    例子一 查询条件dto public class queryCondition{ private String[] stuIds; private String name;} 查询sqlMap < ...

  5. iBATIS使用$和#的一些理解

    我们在使用iBATIS时会经常用到#这个符号. 比如: sql 代码 select * from member where id =#id# 然后,我们会在程序中给id这个变量传递一个值,iBATIS ...

  6. ibatis遍历数组:ParameterObject or property was not a Collection, Array or Iterator.

    这个问题在使用ibatis的<iterate></iterate>时出现的,很简单,但是蛋疼了很久,记下来 首先从错误提示看,明显意思是你给出ibatis的参数不对路,人家不认 ...

  7. iBatis.net 循环iterate,没有foreach

    3.9.4. Iterate Element This tag will iterate over a collection and repeat the body content for each ...

  8. ibatis<iterate>标签

    <iterate  property="" 从传入的参数集合中使用属性名去获取值,   这个必须是一个List类型,   否则会出现OutofRangeException, ...

  9. 值得注意的ibatis动态sql语法格式

    一.Ibatis常用动态sql语法,简单粗暴用一例子 <select id="iBatisSelectList" parameterClass="java.util ...

随机推荐

  1. Delphi的"Invalid pointer operation"异常的解决办法

    今天用Delphi编写了个dll,用到了TStringList来传递多参数,如下: [delphi] view plaincopy 01.function DBM_SetParam(procName: ...

  2. 压力测试之TCPP

    1.下载源码 tpcc-mysql-src.tgz 2.解压 tpcc-mysql-src.tgz 3.安装 [root@DBMysql mysql]# cd /home/mysql/tpcc-mys ...

  3. LinearRegression

    利用python实现简单的线性回归对房屋面积进行预测 # -*-coding:utf-8 -*- ''' Created on 2016年12月15日 @author: lpworkdstudy '' ...

  4. Android--用DownLoadManager下载完成后启动安装

    当我们用系统的服务DownLoadManager下载完成后,系统会发送一个广播,我们只需要注册一个广播,然后在广播里面写如一些相应的操作. 1.注册广播 completeReceiver = new ...

  5. Linux开机启动程序详解

    Linux开机启动程序详解我们假设大家已经熟悉其它操作系统的引导过程,了解硬件的自检引导步骤,就只从Linux操作系统的引导加载程序(对个人电脑而言通常是LILO)开始,介绍Linux开机引导的步骤. ...

  6. iOS进阶学习-数据库

    一.数据库管理系统 1.SQL语言概述:SQL是Structured Query Language(结构化查询语言)的缩写.SQL是专为数据库而建立的操作命令集,是一种功能齐全的数据库语言. 2.常见 ...

  7. 解决Autofac MVC 自动注入在 Areas拆分到不同dll下的注入失败问题

    由于项目业务复杂,创建了多个Areas 并把他们放在了不同的项目中,项目使用AutoFac做的IOC 配置代码为 public class MvcApplication : System.Web.Ht ...

  8. 4.FPGA芯片管脚解释

    用户I/O:不用解释了.   配置管脚: MSEL[1:0] 用于选择配置模式,比如AS.PS等. DATA0 FPGA串行数据输入,连接到配置器件的串行数据输出管脚. DCLK FPGA串行时钟输出 ...

  9. c# 各种排序算法+找第二大的数+句子单词反转

    冒泡排序 // 冒泡排序 bubble sort public static int[] BubbleSort(int []array) { bool isContinue = true; ; i & ...

  10. 微软职位内部推荐-SDEII

    微软近期Open的职位: Software Engineer II for Customer Experience (Level 62+) Location: Suzhou Contact Perso ...