
oracle处理in查询超过1000条报错问题1 通过Lists.partition分批2 分批查询1 通过Lists.partition分批importcom.google.common.collect.Lists;privatevoidchangeBomHandle(ListEBomTcDTOeBomTcDTOList){// 1. 收集bomIdListStringbomIdseBomTcDTOList.stream().map(EBomTcDTO::getBomid).filter(Objects::nonNull).distinct().collect(Collectors.toList());if(bomIds.isEmpty()){return;}// 2. 使用Guava的Lists.partition分批ListEBomTcresultnewArrayList();ListListStringpartitionsLists.partition(bomIds,1000);for(ListStringpartition:partitions){ListEBomTcbatchResulteBomTcRepository.findAllByBomidIn(partition);result.addAll(batchResult);}// 3. 后续业务处理...}2 分批查询privatevoidchangeBomHandle(ListEBomTcDTOeBomTcDTOList){// 1. 收集所有bomIdListStringbomIdseBomTcDTOList.stream().map(EBomTcDTO::getBomid).filter(Objects::nonNull)// 过滤null值.distinct()// 去重可选.collect(Collectors.toList());if(bomIds.isEmpty()){return;}// 2. 分批查询每批最多1000个ListEBomTcresultnewArrayList();intbatchSize1000;for(inti0;ibomIds.size();ibatchSize){intendMath.min(ibatchSize,bomIds.size());ListStringbatchIdsbomIds.subList(i,end);ListEBomTcbatchResulteBomTcRepository.findAllByBomidIn(batchIds);result.addAll(batchResult);}}