ORA-01795: maximum number of expressions in a list is 1000
Oracle 的in query list 的大小要不大于1000,
可以才采用分组query。
List<String> taskLists = new ArrayList<String>(); taskLists.addAll(tasksToArchive); int times = tasksToArchive.size()%1000 == 0 ? tasksToArchive.size()/1000 : (tasksToArchive.size()/1000 +1); List<IAccountingTask> tasksToArchiveList = new ArrayList<IAccountingTask>(); if(taskLists != null) { for(int i=0; i<times; i++) { List<? extends IAccountingTask> tempList = null; if((i+1)*1000 <= taskLists.size()) { tempList = persistenceManager.getSession().getAll(AccountingTask.class, taskLists.subList(i*1000, (i+1)*1000)); } else { tempList = persistenceManager.getSession().getAll(AccountingTask.class, taskLists.subList(i*1000, taskLists.size())); } tasksToArchiveList.addAll(tempList); } }