eclipse 抱怨我的 JPA NamedQuery

eclipse complains about my JPA NamedQuery

出于某种原因,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"

有什么想法吗?

非常感谢

JPQL 不是更新语句的最佳选择,最好只从持久性上下文更新对象或改用本机查询。

我最终通过 JPQL 获取对象并通过 hiberante 脏检查机制修改对象。

如果你的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.