当数据库查询in使用超过1000个的处理方式,in超过1000的问题
数据库查询的时候 ,当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); }