前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mybatis 传入多个list

mybatis 传入多个list

作者头像
IT云清
发布2019-01-22 10:59:27
2.5K0
发布2019-01-22 10:59:27
举报
文章被收录于专栏:IT云清IT云清
mybatis传入多个list集合做参数,很多文章的介绍都是不能实现的,千篇一律的复制,有很大的误导性,这里说一下如何实现:
这里建议你传递对象过来,比如Person对象,里面加入List list1; List list2;….这样,把对象传到mapper.xml中时,取法如下:
dao.java
代码语言:javascript
复制
List<User> find(@Param("person")Person person,@Param("name")String name);
mapper.xml
代码语言:javascript
复制
   <if test="person.list1 != null">
      and id in
      <foreach collection="person.list1" index="index" item="item" open="(" separator="," close=")">
        '${item}'
      </foreach>
    </if>
       <if test="person.list2 != null">
      and id in
      <foreach collection="person.list2" index="index" item="item" open="(" separator="," close=")">
        '${item}'
      </foreach>
    </if>
记录
代码语言:javascript
复制
  <select id="getEidList" resultType="java.lang.String">
    SELECT efe.eid from ent_file_emergent_industry efe,ent_file ef
      where 1 =1
      and efe.eid = ef.eid
      and efe.code in (SELECT code from dict_emergent_industry where type = 2 and remark in (
        <foreach collection="param.customRemarkOrCodeList" index="index" item="item" open="(" separator="," close=")" >
          '${item}'
        </foreach>
      ))
      and ef.plat_from = '${param.platFrom}'
      and ef.delete_flag = 0
  </select>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年04月27日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • mybatis传入多个list集合做参数,很多文章的介绍都是不能实现的,千篇一律的复制,有很大的误导性,这里说一下如何实现:
  • 这里建议你传递对象过来,比如Person对象,里面加入List list1; List list2;….这样,把对象传到mapper.xml中时,取法如下:
    • dao.java
      • mapper.xml
      • 记录
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档