Search code examples
javaeclipsenamed-query

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


Solution

  • JPQL is not the best option for update statements, better to just update the object from the persistence context or use native query instead.

    I ended up fetching the object through JPQL and modify the object through hiberante dirty checking mechanisim.