java - eclipse 提示我的 JPA NamedQuery

标签 java eclipse named-query

出于某种原因,Eclipse IDE 提示我的 JPQL @NamedQuery

Input parameters can only be used in the WHERE clause or HAVING clause of a query.

An association field cannot be used in an update items path expression.

这是我的查询:

"UPDATE ereturn er " +
        "SET " +
        "er.shipper = :shipper, " +
        "er.consignee = :consignee, " +
        "er.notes = :notes, " +
        "er.pickupDateTime = :pickupDate, " +
        "er.productItems = :productItems, " +
        "er.returned = :returned, " +
        "er.returnMethod = :returnMethod, " +
        "er.rma = :rma, " +
        "er.scanDateTime = :scanTime, " +
        "er.status = :status, " +
        "er.dispatchedDate = :dispatchedTime, " +
        "er.barcode = :barcode, " +
        "er.groupName = :groupName " +
        "WHERE er.id = :id"

有什么想法吗?

非常感谢

最佳答案

如果您的JPA版本是2.0或以下,则只能使用WHERE子句参数。

它从 2.1 及更高版本开始发生变化,正如您在 JSR 338: Java TM Persistence API, Version 2.1 的 4.6.4 节中看到的那样

Input parameters can only be used in the WHERE clause or HAVING clause of a query or as the new value for an update item in the SET clause of an update statement.

关于java - eclipse 提示我的 JPA NamedQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52231001/

相关文章:

java - 在 Eclipse 中通过多次调用在单行上打印

java - Eclipse 的 Java 格式化程序能否以不同于新 block 的方式缩进换行?

java - 使用 EclipseLink 在 Oracle 上执行查询时出现奇怪的行为

java.lang.ClassCastException : [Ljava. lang.Long;无法转换为 java.lang.Long

java - hibernate : Resultset mapping in to Map<EntityTypeId, 列表 <EntitiyIds>>

java - Apache Helix 与 YARN

java - 在 Spring MVC 中扩展带注释的 Controller

Android 穿戴示例应用

java - 如何使用互联网时间服务器获取时间?

Java继承-访问私有(private)变量/getClass()