出自:http://blog.csdn.net/u013628152/article/details/51184641

1. findByIds(List ids)

如果参数的类型是List, 则在使用时,collection属性要必须指定为 list

<select id="findByIdsMap" resultMap="BaseResultMap">
Select
<include refid="Base_Column_List" />
from jria where ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>

2:findByIds(Long[] ids)

如果参数的类型是Array,则在使用时,collection属性要必须指定为 array

<select id="findByIdsMap" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tabs where ID in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</select>

3. findByIds(String name, Long[] ids)

当查询的参数有多个时: 
这种情况需要特别注意,在传参数时,一定要改用Map方式, 这样在collection属性可以指定名称

 Map<String, Object> params = new HashMap<String, Object>(2);
params.put("name", name);
params.put("ids", ids);
mapper.findByIdsMap(params);
<select id="findByIdsMap" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tabs where
name = #{name}
and ID in
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
#{item}
</foreach>
</select>
 

最新文章

  1. 用Java代码实现拦截区域网数据包
  2. Python元组
  3. BZOJ2763 [JLOI2011]飞行路线(SPFA + DP)
  4. 【转】HTTP POST GET 本质区别详解
  5. PHP下的命令行执行 php -S localhost -t public
  6. 线程死锁情况和while在线程的作用
  7. hdu3911 线段树 区间合并
  8. C#.Net 图片处理大全
  9. php中body下出现莫名空白字符
  10. 国外一些知名ASP.Net开源CMS系统
  11. BenchmarkDotNet
  12. 机器学习(1)之梯度下降(gradient descent)
  13. JavaBean和EJB的区别
  14. 扔鸡蛋问题具体解释(Egg Dropping Puzzle)
  15. MPMoviePlayerController
  16. HDU1115--Lifting the Stone(求凸多边形的重心)
  17. 使用scrapy爬虫,爬取起点小说网的案例
  18. MVC模式笔记
  19. dojo里添加目录树
  20. svg 认识及动画

热门文章

  1. Apache下配置Openstack Horizon (转)
  2. CSS格式化工具
  3. jQuery AJAX 跨域请求
  4. 【DUBBO】Dubbo原理解析-服务引用
  5. 【spring源码学习】spring的aop目标对象中进行自我调用,且需要实施相应的事务定义的解决方案
  6. SQL的 like 中间字符通配 用法
  7. c++中重载,重写,覆盖
  8. 给 odoo 的 bom 明细加上位置字段
  9. guaua学习,工具专题
  10. Eclipse 创建类时添加继承