gpt4 book ai didi

java - SQL 错误 : 1795, SQLState: 42000 - 列表中表达式的最大数量为 1000

转载 作者:行者123 更新时间:2023-12-01 09:06:14 25 4
gpt4 key购买 nike

SELECT ID FROM PERSON WHERE ID IN (:personIds) AND ( HAS_PAID IS NULL OR HAS_PAID = 'N') ;

在上面的查询中,我传递了之前在我的 Java 应用程序中创建的字符串列表

上面的查询给出了我的应用程序中的某些数据集的以下问题,因为列表 ( 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

有没有办法可以更改我的查询,以便避免出现此错误?

最佳答案

您可以将列表拆分为更小的子列表,然后执行

where foo in (:list1) or foo in (:list2) or ....

关于java - SQL 错误 : 1795, SQLState: 42000 - 列表中表达式的最大数量为 1000,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41264204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com