List<Integer>
Long[]
到此这篇sql里面for循环(sql语句中foreach循环)的文章就介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!1. findByIds(List<Integer> ids) 传入参数为单一list参数时的写法
<foreach item="id" index="index" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
2. findByIds(Integer[] ids) 传入参数为单一数组时的写法
<foreach item="id" index="index" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
3. search(Integer[] ids,String title) 传入参数为多个类型的查询条件时
Map<String, Object> params = new HashMap<String, Object>();
params.put("title", title);
params.put("ids", ids);
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
4.search(Person person) 传入参数为bean对象
<foreach item="id" index="index" collection="person.ids" open="(" separator="," close=")">
#{id}
</foreach>
四种方式应用不同的场景,主要是collection的参数不同————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/gavin5033/article/details/
版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/sqlbc/19823.html