关于mybatis map foreach遍历
前言:
map 数据如下 Map<String,List<Long>>.
测试代码如下:

public void getByMap(){
Map<String,List<Long>> params=new HashMap<String, List<Long>>();
List<Long> orgList=new ArrayList<Long>();
orgList.add(10000003840076L);
orgList.add(10000003840080L);
List<Long> roleList=new ArrayList<Long>();
roleList.add(10000000050086L);
roleList.add(10000012180016L);
params.put("org", orgList);
params.put("role", roleList);
List<BpmDefUser> list= bpmDefUserDao.getByMap(params);
System.out.println(list.size());
}

dao代码如下:
public List<BpmDefUser> getByMap(Map<String,List<Long>> map){
Map<String,Object> params=new HashMap<String, Object>();
params.put("relationMap", map);
return this.getBySqlKey("getByMap", params);
}
xml代码如下:

<select id="getByMap" resultMap="BpmDefUser">
<foreach collection="relationMap" index="key" item="ent" separator="union">
SELECT *
FROM BPM_DEF_USER
where RIGHT_TYPE=#{key}
and OWNER_ID in
<foreach collection="ent" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</foreach>
</select>

index 作为map 的key。item为map的值,这里使用了嵌套循环,嵌套循环使用ent。
关于mybatis map foreach遍历的更多相关文章
- mybatis map foreach遍历
mybatis map foreach遍历 转至http://www.cnblogs.com/yg_zhang/p/4314602.html mybatis 遍历map实例 map 数据如下 Map& ...
- MyBatis map foreach
以下资料来源于网络,仅供参考学习. mybatis 遍历map实例 map 数据如下 Map<String,List<Long>>. 测试代码如下: public vo ...
- Mybatis之foreach用法----List、Array、Map三种类型遍历
在mybatis的xml文件中构建动态sql语句时,经常会用到标签遍历查询条件.特此记录下不同情况下书写方式!-------仅供大家参考------ 1. foreach元素的属性 collectio ...
- js中三个对数组操作的函数 indexOf()方法 filter筛选 forEach遍历 map遍历
indexOf()方法 indexOf()方法返回在该数组中第一个找到的元素位置,如果它不存在则返回-1. 不使用indexOf时 var arr = ['apple','orange','pea ...
- MyBatis的foreach查询(List、Array、Map)
mybatis 中 foreach collection的三种用法 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有 item,index ...
- mybatis的foreach标签
今天写sql发现了一点问题,乱弄了好久算是搞定了.关于mybatis的批量插入使用foreach插入形式为: insert into role_privilege( role_id, privileg ...
- MyBatis之foreach
foreach foreach 元素是非常强大的,它允许你指定一个集合,声明集合项和索引变量,它们可以用在元素体内.它也允许你指定开放和关闭的字符串,在迭代之间放置分隔符.这个元素是很智能的,它不会偶 ...
- mybatis中foreach的用法(转)
foreach一共有三种类型,分别为List,[](array),Map三种. foreach属性 属性 描述 item 循环体中的具体对象.支持属性的点路径访问,如item.age,item.inf ...
- Java集合的Stack、Queue、Map的遍历
Java集合的Stack.Queue.Map的遍历 在集合操作中,常常离不开对集合的遍历,对集合遍历一般来说一个foreach就搞定了,但是,对于Stack.Queue.Map类型的遍历,还是有一 ...
随机推荐
- windows下前端开发工具遇到的问题总结(yeoman bower grunt)
我用的是windows环境 一毕要环境: 1:nodejs 官网:https://nodejs.org/en/ 2:由于很多国外网站国内都访问不了(如果没有设置会出现很多奇怪的错误),所有必需FQ 我 ...
- [LeetCode&Python] Problem 167. Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that the ...
- a标签总结
一.<a>定义和用法 <a> 标签定义超链接,用于从一张页面链接到另一张页面. <a> 元素最重要的属性是 href 属性,它指示链接的目标. 在所有浏览器中 ...
- lesson1-fastai
fast-ai系统资料https://www.jianshu.com/p/2fe22a6b0ecb 中文视频 https://www.bilibili.com/video/av10156946/ind ...
- c标签取数组中的对象值的2种方法
1:循环遍历 <c:forEach items="${partsDeltailsList}" var="var" varStatus="vs&q ...
- LOJ 6277:数列分块入门 1(分块入门)
#6277. 数列分块入门 1 内存限制:256 MiB时间限制:100 ms标准输入输出 题目类型:传统评测方式:文本比较 上传者: hzwer 提交提交记录统计讨论 3 测试数据 题目描述 给出一 ...
- German Collegiate Programming Contest 2013-B:Booking(贪心)
Booking Pierre is in great trouble today! He is responsible for managing the bookings for the AC ...
- Python算法——递归思想
编程语言在构建程序时的基本操作有:内置数据类型操作.选择.循环.函数调用等,递归实际属于函数调用的一种特殊情况(函数调用自身),其数学基础是数学归纳法.递归在计算机程序设计中非常重要,是许多高级算法实 ...
- generator插件配置方式使用
generator插件配置方式使用 <build> <plugins> <plugin> <groupId>org.mybatis.generator& ...
- python------模块定义、导入、优化 ------->random模块
2.random模块 #随机浮点数 random.random() #生成0到1之间的随机浮点数,不能自己指定 random.uniform(1,10) #可以指定 #随机整数 random. ...