PersonDaoImp如下:

  /**
    * 删除性别为man,年龄为 11,12 的Person记录
    */
  public int deletePerson(Map<String, Object> map) {
         
         List<Person> personList=new ArrayList<Person>();

Person p1=new Person(11);
         person p2=new Person(12);
         personList.add(p1);
         personList.add(p2);

map.put("personList", personList);

map.put("sex",'man');
         return getSqlMapClientTemplate().delete(
                                 "person.deletePerson", map);
     }

person.xml如下:

<!-- 删除相应的person记录 -->
  <delete id="deletePerson" parameterClass="map">

delete from 表名 where      sex=#sex#         
        <iterate prepend="and" property="personList" open="("
          close=")" conjunction="or">
          age=$personList[].age$
        </iterate> 
       
  </delete>

输出sql如下:
delete from 表名 where sex='man' and (age =11 or age=12)

当然你也可以这么写:
person.xml如下:

<!-- 删除相应的person记录 -->
  <delete id="deletePerson" parameterClass="map">

delete from 表名 where      sex=#sex#     and age in   
        <iterate property="personList" open="("
          close=")" conjunction=",">
          $personList[].age$
        </iterate> 
       
  </delete>

输出sql如下:
delete from 表名 where sex='man' and  age in (11 ,12)

最后Person代码大致如下:

public class Person{
  public Person(int age){
      this.age=age;
  }
  /**
    * 年龄
    */
  private int age;
  /**
    * 性别
    */
  private String sex;
  
   //get/set方法略
   ...
 }//end of Person

ibatis中iterate的用法(转载)相关推荐

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

    <!-- 删除相应的person记录  -->   < delete  id =" deletePerson "  parameterClass ="m ...

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

    <!-- 删除相应的person记录  -->   < delete  id =" deletePerson "  parameterClass ="m ...

  3. iterate java_ibatis中iterate的用法(conjunction=or ,)

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

  4. matlab stem函数坐标轴_MATLAB中stem函数用法

    stem(Y) 将数据序列Y从x轴到数据值按照茎状形式画出,以圆圈终止.如果Y是一个矩阵,则将其每一列按照分隔方式画出. stem(X,Y)在X的指定点处画出数据序列Y.  stem(...,'fil ...

  5. matlab中struct2,Matlab中struct的用法

    struct在matlab中是用来建立结构体数组的.通常有两种用法: s = struct('field1',{},'field2',{},...) 这是建立一个空的结构体,field1,field2 ...

  6. python中with是什么意思,Python中With的用法

    在看Dive Into Python中有关描述文件读写那章节的时候,看到了有关with的用法,查阅下相关资料,记录下来,以备后用. 官方的reference上有关with statement是这样说的 ...

  7. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  8. [转载] python里字典的用法_python中字典(Dictionary)用法实例详解

    参考链接: Python字典dictionary copy方法 本文实例讲述了python中字典(Dictionary)用法.分享给大家供大家参考.具体分析如下: 字典(Dictionary)是一种映 ...

  9. format函数python的顺序_[转载] Python中format函数用法

    Python中format函数用法 format优点 format是python2.6新增的格式化字符串的方法,相对于老版的%格式方法,它有很多优点. 1.不需要理会数据类型的问题,在%方法中%s只能 ...

最新文章

  1. SLAM工具|GDB调试从入门到精通
  2. php内加百度熊掌号,百度熊掌号接入网站页面改造详细步骤
  3. TureType/OpenType 字体瘦身、字体转换和字符替换
  4. 华为发布最强服务器芯片,[百家号]华为:最强ARM服务器芯片,华为鲲鹏920处理器发布...
  5. mysql复制模式第二部分-----双主模式
  6. pytorch搭建TextRCNN模型与使用案例
  7. TextBlock or Label?
  8. 2017 前端大事件和趋势回顾,2018 何去何从?
  9. BZOJ-1050-[HAOI2006]旅行comf(并查集)
  10. 在word中添加内容控件,报错未实现该方法或操作
  11. Linux下comm命令比较两个文件的异同
  12. python 91图片站爬虫
  13. RoI Pooling 和 RoI Align
  14. Pure Virtual Function
  15. Keil、uVision、RealView、MDK、Keil C51之间的区别
  16. 计算机网络(IP/TCP/HTTP)
  17. 基于CAD的花灯制作
  18. android 神气插件 自动补全tabnine
  19. SAT数学考试需要准备的物品
  20. C++使用Clipper库

热门文章

  1. phpstudy小皮 反向代理
  2. html翻牌小游戏自定义,js 翻牌小游戏
  3. [Hades_方法]Hades学习方法和资料
  4. 区块链技术性感依旧:咔咔房链想吃REITs这个大蛋糕
  5. 【AD】差分布线/蛇形布线/等长布线
  6. 电子笔记本的思考(1)(ver0.2)
  7. 揭开iphone4 4S 5 之间的内幕!这次你们该相信了吧!
  8. 首届幼教生态共融体系战略伙伴私享会在湖南省智慧教育装备展示体验中心举行
  9. 热门好用的二维码识别API
  10. 耀眼的天才——Aaron Swartz提高效率的秘诀