i had the following jpql in my java jee services bean:
select tad from TADS tad WHERE tad.agreementOwnerId = :agreementOwnerId AND upper(tad.transportCompany.name) LIKE :transporter.name ORDER BY tad.agreementNumber DESC, tad.id DESC
when i tried running the query i got the following error:
"unexpected AST node: :"
after some testing i found out that jpql query named parameters can't contain characters that are not a valid identifier as defined by Character.isJavaIdentifierPart e.g. period/full stop character (".").
e.g. a named parameter like "transporter.name" is invalid
the error message "unexpected AST node: :" was complaining about the ":" next to the named parameter "transporter.name", but the real problem was the "." in the named parameter. the named parameter should be rewritten to be something like "transporterName"
DOH!
so, this jqpl query string works:
select tad from TADS tad WHERE tad.agreementOwnerId =
:agreementOwnerId AND upper(tad.transportCompany.name) LIKE
:transporterName ORDER BY tad.agreementNumber DESC, tad.id DESC
afterwards, i found that this is also explained at stackoverflow:
JPA NamedQuery parameters
IT, computer and programming tutorials and tips that i couldnt find anywhere else using google, from my daily work as a Senior Developer of solutions using Java and Linux.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment