eclipse complains about my JPA NamedQuery
eclipse complains about my JPA NamedQuery
For some reason eclipse IDE complains about my JPQL @NamedQuery
Input parameters can only be used in the WHERE clause or HAVING clause
of a query.
and
An association field cannot be used in an update items path
expression.
this is my query:
"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"
Any thoughts?
thank you very much
2 Answers
2
JPQL is not the best option for update statements, better to just update the object from the persistence context or use native query instead
If your JPA version is 2.0 or below, you can only use parameters is the WHERE clause.
It changes from version 2.1 and above, as you can see in the section 4.6.4 of the JSR 338: Java TM Persistence API, Version 2.1
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.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.