1、查询int 数组

dao类:

public List<Integer> queryRoleIdList(Integer userId);

service类:

List<Integer> userIdList=userRoleService.queryRoleIdList(userId);

<select id="queryRoleIdList" resultType="int">
select
role_id
from
userbase_role
where
user_id=#{userId}
</select>

查询出的结果为[x,y];

2、mybatis  使用in

dao类:

public List<RoleResourceBean> queryByRoleId(List<Integer> list);

service类:

/**
* 根据用户角色获取用户权限
* @param roleId
* @return
*/
public List<RoleResourceBean> queryByRoleId(List<Integer> list){
return dao.queryByRoleId(list);
}

mybatis:

<select id="queryByRoleId" resultMap="roleResourceMap" parameterType="java.util.List">
select
id,
<include refid="requiredColumn" />
from
role_module
where
role_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>

结果为select * from table where id in(x,y)

参考:http://www.cnblogs.com/mingyue1818/p/3714162.html

最新文章

  1. angularjs学习总结 详细教程(转载)
  2. 东大OJ-1051-旅行家的预算
  3. windows编程中c语言知识回顾
  4. PHP的基本语法
  5. request请求对象实例
  6. [转载]charisma-master 加载慢的原因及解决方法
  7. jquery html 动态添加元素绑定事件
  8. c++基础 之 面向对象特征一 : 继承
  9. Linux $( )与${ }的区别
  10. Django入门实践(三)
  11. AngularJS高级程序设计读书笔记 -- 服务篇
  12. Linux系统 磁盘IO过高排查总结
  13. PHP 开发者的 Docker 之旅
  14. python3:实现字符串的全排列(无重复字符)
  15. node.js认识及学习资料
  16. ASP HUOSHAN VIDEO
  17. 【壹拾壹周】final_review
  18. SharePoint 2013创建应用程序时IIS端口文件夹下没文件
  19. HDU 3949 XOR 线性基
  20. JSON数据转换成table表格

热门文章

  1. CALayer的基本使用
  2. 安装vs2012以后 sql2008不能使用解决办法
  3. IDEA创建MAVEN 无骨架WEB 项目
  4. Contentprovider的创建和使用流程概述
  5. Winform状态栏控件中Label靠右显示的方法
  6. ZXing开发详解
  7. Pig Latin程序设计1
  8. boost::python的使用
  9. Advanced WordCount
  10. jQuery CSS 操作