I'm using Hibernate 3.5.4-Final.
I want to pass an entity as a parameter of a named query, and then access a persisted property of that named parameter in that query. I want to do this:
@NamedQuery(name = "hello", query = "SELECT p FROM WorkPackage p WHERE p IN (:workPackage).relatedWorkflows")
The problem is near the end of the query, in the
(:workPackage).relatedWorkflows
which causes Hibernate to throw a deploy-time QuerySyntaxException. Remove the parentheses doesn't help; I left them in for clarity. Is there any way around this, or am I going to have to do this programmatically?
You can't. You have to pass the property value itself to the query:
@NamedQuery(name = "hello", query = "SELECT p FROM WorkPackage p WHERE p IN (:relatedWorkflows)")
query.setParameterList("relatedWorkflows", workPackage.getRelatedWorkflows());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With