-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL for objects with at least one matching element in coll?
PostPosted: Thu Sep 25, 2003 10:08 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
Any help on this would be appreciated. I've got an object with a one-to-many relationship mapped as a Set (user.roles). Given a list of roles, how can I return the users with at least one matching element?

Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 10:30 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
The easiest would be to use the role ids like:
Code:
Query qry = session.createQuery("from User as u join u.roles as r where r.id in (:roleIds)");
qry.setParameterList("roleIds", roleIdList);
return qry.find();


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Thu Sep 25, 2003 10:58 pm 
Beginner
Beginner

Joined: Tue Aug 26, 2003 4:19 pm
Posts: 42
Thank you Steve, that did the trick!


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