Hi,
I've had a look and I beleive you can't use the Expression.in(String, Object[]) with named parameters in named queries.
If I could say in my named query:
from User user
where user.email in (:emailList)
And then substitue the 'emailList' named parameter with this code:
String[] emails = { "foo@bar.com", "bar@foo.com"};
List results = session.getNamedQuery("getUsersByEmailAddress")
.setIn(Expression.in("emailList", emails ))
.list();
Or maybe it would be
setIn("emailList", emails)
or some other variation on that, it would make my life easier.
After writing all this I realised that this may be a JDBC driver limitation and would require the SQL to be generated each time a named query is loaded but all that said this would be a cool feature for future releases.
If anyone has any ideas on the best way to hand "in" with named queries please let me know.
End rant
Adrian
|