SQL错误:1795,SQLState:42000 - 列表中的最大表达式数为1000(SQL Error: 1795, SQLState: 42000 - maximum number of expressions in a list is 1000)
SELECT ID FROM PERSON WHERE ID IN (:personIds) AND ( HAS_PAID IS NULL OR HAS_PAID = 'N') ;
在上面的查询中,我传递了一个在我的Java应用程序中先前创建的字符串list 。
上面的查询给出了我的应用程序中的一些数据集的以下问题,因为列表(personIds)包含超过1000个成员:
WARN o.h.internal.AbstractQueryImpl - HHH000443: Dialect [org.hibernate.dialect.Oracle10gDialect] limits the number of elements in an IN predicate to 1000 entries. However, the given parameter list [personIds] contained 1041 entries, which will likely cause failures to execute the query in the database WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 1795, SQLState: 42000 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ORA-01795: maximum number of expressions in a list is 1000有没有办法可以更改我的查询,以便我可以解决这个错误?
SELECT ID FROM PERSON WHERE ID IN (:personIds) AND ( HAS_PAID IS NULL OR HAS_PAID = 'N') ;Into the query above I am passing a list of strings created earlier in my Java application.
The above query is giving is giving the following issue for some data sets within my application as the list ( personIds ) contains over 1000 members:
WARN o.h.internal.AbstractQueryImpl - HHH000443: Dialect [org.hibernate.dialect.Oracle10gDialect] limits the number of elements in an IN predicate to 1000 entries. However, the given parameter list [personIds] contained 1041 entries, which will likely cause failures to execute the query in the database WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 1795, SQLState: 42000 ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ORA-01795: maximum number of expressions in a list is 1000Is there a way I can change my query so that I can get around this error from occurring?
最满意答案
您可以将列表拆分为较小的子列表,然后执行
where foo in (:list1) or foo in (:list2) or ....You can split your list into smaller sublists, and do
where foo in (:list1) or foo in (:list2) or ....更多推荐
发布评论