MySQL批量查询
public List<Long> batchSelectImageIds(Long templateId){List<Long> imageIdList = new ArrayList<>();int count = templateBlackImageRelMapper.selectImageCount(templateId);int limit = 500
·
//分批查询:
public List<Task> batchSelectTaskList(Long id){
List<Task> taskList = new ArrayList<>();
int count = mapper.selectTaskCount(id);
int limit = 500;
int batchSelectCount = count%limit == 0 ? count/limit : count/limit+1;
int start = 0;
int end = 0;
for(int i=1;i<=batchSelectCount;i++){
//end = i==batchSelectCount ? end+count%limit : end+limit;
end = end+limit;
List<Task> subTaskList = mapper.batchSelect(id,start,limit);
start = end;
taskList.addAll(subTaskList);
}
return taskList;
}
更多推荐
已为社区贡献1条内容
所有评论(0)