-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Using Expression.in() with named paramaters
PostPosted: Wed May 19, 2004 10:07 pm 
Newbie

Joined: Tue Apr 27, 2004 1:10 am
Posts: 3
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 10:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
List results = session.getNamedQuery("getUsersByEmailAddress")
.setParameterList("emailList", emails)
.list();

The Expression stuff is used in QBC API stuff, not in HQL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.