根据List mybatis批量查询List结果
2015-09-09 18:21
309 查看
mapper 文件
mapper.xml文件
@Repository public interface UserMapper { List<String> queryNamesByIds(Map<String, Object> userIdsParam); } @Named public class UserServiceImpl implements UserService { @Override public List<String> queryNamesByIds(List<Integer> userIds) { Map<String, Object> userIdsParam = new HashMap<String, Object>(); userIdsParam.put("userIds", userIds); return this.userMapper.queryNamesByIds(userIdsParam); } }
mapper.xml文件
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.mybatis.mapper.UserMapper"> <select id="queryNamesByIds" resultType="java.lang.String"> SELECT name from user WHERE id in <foreach collection="userIds" item="id" open="(" close=")" separator=","> #{id} </foreach> </select> </mapper>
相关文章推荐
- 新疆股权投资企业税收优惠政策
- MyBatis调用存储过程
- checkbox实现全选,全不选,反选。Bootstrap-用ICheck插件给CheckBox换新装!
- 【抽象代数】 06 - 理想与直和
- CALayer动画实践(二):CAReplicatorLayer的用法
- MyBatis实现关联表查询
- webview回调函数没反应
- css3实现动画横幅
- Mongo db 与mysql 语法比较
- 你会用finally吗?
- quartz 2.0
- POJ-1062 昂贵的聘礼
- 公告:消息系统停站维护公告
- wix开机启动
- uva 10534 Wavio Sequence
- CALayer Animation实践(一):让应用灵动起来!
- Android 读取工程中的txt文件
- webRTC resource
- HDU-A Corrupt Mayor's Performance Art【线段树+位运算】
- android中MVP模式