數據庫查詢的時候 ,當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); }
