-->
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.  [ 5 posts ] 
Author Message
 Post subject: elements() and subselects
PostPosted: Fri Aug 27, 2004 3:41 pm 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
Hibernate version:
2.1.6

Is it legal to compare an elements() clause against a subselect? E.g.

Code:
select from Parent p where some elements(p.children) in (select from Children c where c.big.long.complex.path.here = ?)


Having some trouble with undefined aliases when I try to run this query. Is this totally not allowed? Should we be doing a join query instead and take care of getting unique parents ourselves?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 3:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes, use a join.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 3:52 pm 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
Fair enough, but is there any way to get unique parents in hql? e.g.

Code:
select unique Parent p join p.children ...


or do we have to do that in Java? That's the only reason we were messing about with the elements() pseudofunction stuff in the first place.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 4:02 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
Could you not use "select distinct..."?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 4:11 pm 
Regular
Regular

Joined: Fri Aug 29, 2003 12:48 pm
Posts: 63
unique == distinct

But apparantly not, unless we were borking the hql in some fashion. Was hoping for definitive word on doing unique/distinct queries with joins, it doesn't seem to work or even make sense offhand.


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