-->
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 ] 

So now that Opera is free, will you use it?
Poll ended at Fri Oct 07, 2005 4:34 pm
Yes 25%  25%  [ 1 ]
No 75%  75%  [ 3 ]
I paid for it 0%  0%  [ 0 ]
Total votes : 4
Author Message
 Post subject: HQL count expression in where clause
PostPosted: Fri Sep 23, 2005 4:34 pm 
Regular
Regular

Joined: Fri May 13, 2005 4:08 pm
Posts: 64
I need to select all entity A's where parent entity B has a collection of child entity C with at least one entity.
I think in HQL it ought to be something like this:
Code:
from A a where count(a.B.C) > 0

That is, in SQL:
Code:
SELECT * FROM A a WHERE (SELECT COUNT(*) FROM C c WHERE c.bId = a.bId) > 0

I've read through the HQL documentation offered at http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html, but my question isn't answered there.

Can anyone advise me, please? I've tried a dozen different variations of HQL that I think might work to no avail.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 24, 2005 3:44 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
What about this?
Code:
from A a where a.B.C.size > 0


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.