SQL错误:1795,SQLState:42000

编程入门 行业动态 更新时间:2024-10-15 04:22:51
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 1000

Is 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 ....

更多推荐

本文发布于:2023-08-05 19:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1437719.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   SQL   SQLState

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!