-->
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: how to use left join to get collection size
PostPosted: Wed Oct 22, 2003 5:12 am 
Newbie

Joined: Thu Aug 28, 2003 8:41 pm
Posts: 17
Code:
select count( elements(cat.kittens) ) from eg.Cat cat group by cat

This query use inner join

Code:
select count( elements(cat.kittens) ) from eg.Cat cat left join cat.kittens group by cat

This query generate sql like
Code:
select count(kittens2_.id) as x0_0_ from Cat cat0_ left outer join Cat kittens1_ on
cat0_.id=kittens1_.parentId, Cat kittens2_ where cat0_.id=kittens2_.parentId group by  cat0_.id


Code:
select count( elements(kittens) )  from eg.Cat cat left join cat.kittens as kittens group by cat

This query does not work.

How can I do this?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 5:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Code:
select count(kit) from Cat cat left join cat.kittens kit group by cat


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 9:54 pm 
Newbie

Joined: Thu Aug 28, 2003 8:41 pm
Posts: 17
Yeah, it does work, thanks.


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.