-->
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.  [ 4 posts ] 
Author Message
 Post subject: using "in" in HQL over a Set
PostPosted: Mon Jun 14, 2004 8:47 am 
Beginner
Beginner

Joined: Thu Mar 25, 2004 9:13 am
Posts: 20
I want to use HQL "in" option in the following way:

Code:
public void foo(Set s) {
    String q = "select request from request in class " + getTheClass()
                + " where request.networkId in elements(...)";

    ...
}


while the ... in the elements() should be replaced by the Set that the method gets as an argument. How is it done? I could find an example for it.

TIA Oren

_________________
Oren Gross


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 8:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
use a collection filter?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 9:06 am 
Beginner
Beginner

Joined: Thu Mar 25, 2004 9:13 am
Posts: 20
Can you please elaborate on that? the only place I read about filter() is at http://www.hibernate.org/hib_docs/refer ... tions.html and I don't see how it help me.

TIA

_________________
Oren Gross


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 9:24 am 
Beginner
Beginner

Joined: Thu Mar 25, 2004 9:13 am
Posts: 20
found it...
Code:
List names = new ArrayList();
names.add("Izi");
names.add("Fritz");
Query q = sess.createQuery("from DomesticCat cat where cat.name in (:namesList)");
q.setParameterList("namesList", names);
List cats = q.list();

from chapter 9.3.2. The Query interface

_________________
Oren Gross


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.