gpt4 book ai didi

hibernate - 将参数传递给 HQL

转载 作者:行者123 更新时间:2023-12-03 13:54:58 25 4
gpt4 key购买 nike

我有一个变量,如 long[] ids = [10, 11]我正在尝试像这样触发查询:

Query query2 = session.createQuery("update Employee e SET e.isLatest = false where e.id not in (:ids)");
query2.setParameter("ids", ids);
query2.executeUpdate();

但我收到了类似的错误
org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint <> character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.

如何在 NOT IN 中传递数组变量范围?或者有没有其他方法来处理这样的查询?

最佳答案

尝试

query2.setParameterList("ids", ids);

关于hibernate - 将参数传递给 HQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17987031/

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