-->
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 question - Collection equality
PostPosted: Thu Sep 06, 2007 4:36 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Hello,


How can I check if a given collection parameter is a subset of an entity's association? For example, imagine we have a Person that has a list of places he/she has visited, namely locations. How can I get a list of persons who have visited an arbitrary list of locations? Something like :collectionParameter is memberOf person.locations. Is this a valid hql query?


Thanks,
Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 6:25 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
you will possibly have to do join the places multiple times. HQL has to be translated in SQL and what you are looking for does not exist as far as I know not in SQL.

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 6:38 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
How about this one?

select p from Person
where
(select count(*) from p.locations l where l in elements(:collectionParameter)) = :sizeOfCollection


It might not make sense at all because I don't know if expression functions that work on an association would also work on a collection parameter.


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.