数据库查询的时候 ,当in里面的参数个数大于1000以后就会报错

大体思路  就是把sql改成 in() or in  ()的结果 

入参的list进行截取 

 

mybatis中xml的写法

        and
        <foreach collection="list" item="item" open="(" separator="or" close=")">
         t1.USER_ID in
        <foreach item="item2" index="index" collection="item" open="(" close=")" separator=",">
            #{item2.userId}
        </foreach>
        </foreach>

入参时的写法

        List<List<VacationsExport>> agreementNumberList = new ArrayList<List<VacationsExport>>();
        int size = mapList.size();
        int count = (size + splitNumber - 1) / splitNumber;
        for (int i = 0; i < count; i++) {
            List<VacationsExport> subList = mapList.subList(i * splitNumber, ((i + 1) * splitNumber > size ? size : splitNumber * (i + 1)));
            agreementNumberList.add(subList);
        }

 

相关文章:

  • 2023-03-19
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-19
猜你喜欢
  • 2022-12-23
  • 2021-09-23
  • 2022-01-15
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案