javajpaejbql

Can EJBQL Named Paremeters be Repeated in a Query?


Just a quick one. If I'm using an EJBQL query with named parameters, can I use the same parameter name twice in a single query to avoid having to set the value twice when I actually want to run the query? For instance, I'd like to be able to do something like this:

SELECT g FROM Group g WHERE g = :group OR g.parent = :group

...so that doing:

query.setParameter("group", theGroup);

will populate both fields. Is this possible?

I realize I could just run this and see, but I figured that asking first might save me (and anyone else who happens to find this question) a bit of time and frustration.


Solution

  • Yes, it's part of the spec. Makes no sense for a spec to insist on passing in an extra param name with dup value