首页 > 其他 > 详细

mybatis map foreach遍历

时间:2016-03-20 21:28:34      阅读:251      评论:0      收藏:0      [点我收藏+]

mybatis map foreach遍历

转至http://www.cnblogs.com/yg_zhang/p/4314602.html

mybatis 遍历map实例

map 数据如下 Map<String,List<Long>>.

 

测试代码如下:

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代码如下:

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遍历

原文:http://www.cnblogs.com/xuerong/p/5299498.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!