-->
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: Formulate query for WHERE IN LIST
PostPosted: Wed Nov 28, 2007 3:00 pm 
Newbie

Joined: Wed Nov 28, 2007 2:43 pm
Posts: 1
I'm having trouble finding any documentation that shows how to build an IN LIST clause without having to manually construct the SQL.

For example, here's a sample query I'm trying to get Hibernate to produce...

Code:
SELECT x FROM y WHERE z IN LIST ('A','B','C','D');


Essentially, I'm wanting to get a collection of 'x' objects based on a list of identifiers ('A','B','C','D').

The alternative I've been using is to make multiple SELECT calls...
Code:
SELECT x FROM y WHERE z = 'A';
SELECT x FROM y WHERE z = 'B';
SELECT x FROM y WHERE z = 'C';
SELECT x FROM y WHERE z = 'D';


... and stuff each individual result into a collection.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 28, 2007 5:26 pm 
Newbie

Joined: Thu Oct 25, 2007 3:17 pm
Posts: 8
queryObject.createQuery("select obj from object obj where obj.property in (:someCollection)");

queryObject.setParameterList("someCollection",javaCollection) ;

should do what your looking for


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.