前言:

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遍历的更多相关文章

  1. mybatis map foreach遍历

    mybatis map foreach遍历 转至http://www.cnblogs.com/yg_zhang/p/4314602.html mybatis 遍历map实例 map 数据如下 Map& ...

  2. MyBatis map foreach

    以下资料来源于网络,仅供参考学习.   mybatis 遍历map实例 map 数据如下 Map<String,List<Long>>.   测试代码如下: public vo ...

  3. Mybatis之foreach用法----List、Array、Map三种类型遍历

    在mybatis的xml文件中构建动态sql语句时,经常会用到标签遍历查询条件.特此记录下不同情况下书写方式!-------仅供大家参考------ 1. foreach元素的属性 collectio ...

  4. js中三个对数组操作的函数 indexOf()方法 filter筛选 forEach遍历 map遍历

     indexOf()方法  indexOf()方法返回在该数组中第一个找到的元素位置,如果它不存在则返回-1. 不使用indexOf时 var arr = ['apple','orange','pea ...

  5. MyBatis的foreach查询(List、Array、Map)

    mybatis 中 foreach collection的三种用法 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有 item,index ...

  6. mybatis的foreach标签

    今天写sql发现了一点问题,乱弄了好久算是搞定了.关于mybatis的批量插入使用foreach插入形式为: insert into role_privilege( role_id, privileg ...

  7. MyBatis之foreach

    foreach foreach 元素是非常强大的,它允许你指定一个集合,声明集合项和索引变量,它们可以用在元素体内.它也允许你指定开放和关闭的字符串,在迭代之间放置分隔符.这个元素是很智能的,它不会偶 ...

  8. mybatis中foreach的用法(转)

    foreach一共有三种类型,分别为List,[](array),Map三种. foreach属性 属性 描述 item 循环体中的具体对象.支持属性的点路径访问,如item.age,item.inf ...

  9. Java集合的Stack、Queue、Map的遍历

    Java集合的Stack.Queue.Map的遍历   在集合操作中,常常离不开对集合的遍历,对集合遍历一般来说一个foreach就搞定了,但是,对于Stack.Queue.Map类型的遍历,还是有一 ...

随机推荐

  1. camp待补

    待修莫对 序列自动机 几何积分 沈阳 M 待删除背包  : 分组背包 K-LIS, K次二分(插到最后stop) 问题转化为LIS bzoj2131 hdu4055 最小线段覆盖环 实时路况 分治+f ...

  2. POJ 3468:A Simple Problem with Integers(线段树区间更新模板)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 141093 ...

  3. Python开发指南规范

    分号 不要在行尾加分号, 也不要用分号将两条命令放在同一行. 行长度 每行不超过80个字符 例外: 长的导入模块语句 注释里的URL 不要使用反斜杠连接行. Python会将 圆括号, 中括号和花括号 ...

  4. 《DSP using MATLAB》Problem 5.12

    1.从别的地方找的证明过程: 2.代码 function x2 = circfold(x1, N) %% Circular folding using DFT %% ----------------- ...

  5. LeetCode - Is Graph Bipartite?

    Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...

  6. C++中的类模板

    一.学习笔记 1.类模板的格式(1)声明 template<typename T> /* 使用T表示某种类型,比如: */ class AAA { private: T obj; publ ...

  7. What's New In Zeebe: Scaling Zeebe, New Client APIs, Faster Requests, Timestamps, NodeJS Client, and Default Topic is Back!

    Written by Daniel Meyer on May 16 2018 in the What's New In Zeebe category. Welcome to the first-eve ...

  8. 侃侃Thinking In Java

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/yqj2065/article/details/37074503 对于大学生,yqj2065不推荐Th ...

  9. Zabbix-2.4-安装-4

    Zabbix api 对于以上两种方式,有些人都不选,倾向于使用第三种:使用zabbix api加上这个监控在把这台机器删除了,然后discovery和自动注册的都关闭了再换一种方式把它加进去,zab ...

  10. hadoop mapreduce 简单例子

    本例子统计 用空格分开的单词出现数量(  这个Main.mian 启动方式是hadoop 2.0 的写法.1.0 不一样 ) 目录结构: 使用的 maven : 下面是maven 依赖. <de ...