Oracle 错误:ORA-01795: maximum number of expressions in a list is 1000

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);
    }
            
}

 

posted @ 2017-07-18 14:52  二更  阅读(3106)  评论(0编辑  收藏  举报