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