mybatis map foreach遍历
2016-04-14 13:22
441 查看
mybatis map foreach遍历 mybatis 遍历map实例 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
相关文章推荐
- swift nsarray中加nsarray、NSMutableArray
- 网马检测
- 微信朋友圈图片处理策略
- 快速幂
- MySQL单列索引和组合索引
- iOS 一套@3x图片兼容所有iOS设备和系统
- 快速幂
- Ubuntu相关命令
- 珍惜
- FZU 2087 统计树边【MST相关】
- 234. Palindrome Linked List
- Android Studio 环境配置优化
- android studio多渠道打包,且根据buildConfig属性判断为哪个渠道升级或者实现不同业务逻辑
- QtCreator:项目中文件按类别放入不同子文件夹
- linux模块导出符号 EXPORT_SYMBOL_GPL EXPORT_SYMBOL
- Android 代码动态改变View的属性
- JDK、Tomcat、ANT及Eclipse常用配置
- LVS Funnat 编译安装使用
- codeforces 660A
- MVC下拉框Html.DropDownList 和DropDownListFor 的常用方法