ibatis中iterate的用法(转载)
* 删除性别为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如下:
<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如下:
<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 Person(int age){
this.age=age;
}
/**
* 年龄
*/
private int age;
/**
* 性别
*/
private String sex;
//get/set方法略
...
}//end of Person
ibatis中iterate的用法(转载)相关推荐
- ibatis中iterate的用法(conjunction=or ,) .
<!-- 删除相应的person记录 --> < delete id =" deletePerson " parameterClass ="m ...
- ibatis中iterate的用法(conjunction=or ,)
<!-- 删除相应的person记录 --> < delete id =" deletePerson " parameterClass ="m ...
- iterate java_ibatis中iterate的用法(conjunction=or ,)
例子一 查询条件dto public class queryCondition { private String[] stuIds; private String name; } 查询sqlMap s ...
- matlab stem函数坐标轴_MATLAB中stem函数用法
stem(Y) 将数据序列Y从x轴到数据值按照茎状形式画出,以圆圈终止.如果Y是一个矩阵,则将其每一列按照分隔方式画出. stem(X,Y)在X的指定点处画出数据序列Y. stem(...,'fil ...
- matlab中struct2,Matlab中struct的用法
struct在matlab中是用来建立结构体数组的.通常有两种用法: s = struct('field1',{},'field2',{},...) 这是建立一个空的结构体,field1,field2 ...
- python中with是什么意思,Python中With的用法
在看Dive Into Python中有关描述文件读写那章节的时候,看到了有关with的用法,查阅下相关资料,记录下来,以备后用. 官方的reference上有关with statement是这样说的 ...
- [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法
一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...
- [转载] python里字典的用法_python中字典(Dictionary)用法实例详解
参考链接: Python字典dictionary copy方法 本文实例讲述了python中字典(Dictionary)用法.分享给大家供大家参考.具体分析如下: 字典(Dictionary)是一种映 ...
- format函数python的顺序_[转载] Python中format函数用法
Python中format函数用法 format优点 format是python2.6新增的格式化字符串的方法,相对于老版的%格式方法,它有很多优点. 1.不需要理会数据类型的问题,在%方法中%s只能 ...
最新文章
- SLAM工具|GDB调试从入门到精通
- php内加百度熊掌号,百度熊掌号接入网站页面改造详细步骤
- TureType/OpenType 字体瘦身、字体转换和字符替换
- 华为发布最强服务器芯片,[百家号]华为:最强ARM服务器芯片,华为鲲鹏920处理器发布...
- mysql复制模式第二部分-----双主模式
- pytorch搭建TextRCNN模型与使用案例
- TextBlock or Label?
- 2017 前端大事件和趋势回顾,2018 何去何从?
- BZOJ-1050-[HAOI2006]旅行comf(并查集)
- 在word中添加内容控件,报错未实现该方法或操作
- Linux下comm命令比较两个文件的异同
- python 91图片站爬虫
- RoI Pooling 和 RoI Align
- Pure Virtual Function
- Keil、uVision、RealView、MDK、Keil C51之间的区别
- 计算机网络(IP/TCP/HTTP)
- 基于CAD的花灯制作
- android 神气插件 自动补全tabnine
- SAT数学考试需要准备的物品
- C++使用Clipper库