-->
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 ] 
Author Message
 Post subject: Count all children of all parents
PostPosted: Sun Sep 21, 2008 4:18 pm 
Newbie

Joined: Sun Sep 21, 2008 4:10 pm
Posts: 3
I'm using NHibernate 2.0, but that really doesn't matter.

What I'm trying to do is calculate the sum of all children for a given table.
My query is:
Code:
select count(*) from Bestla.DBMap.News t1 join t1.PItem.Locales t2 where t2.Culture = 1 group by t1.ID


However, instead of working as its SQL equivalent, the query returns an array where each row is a count of children for each object, while I need the sum. So if there are 6 objects with 2 children each the result should be 12.

Can anyone provide a way this is actually supposed to be done in NHibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 5:37 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
When you specifiy a group by I would expect the described behavior even with plain sql. If you omit the group by you should get the result you want.

_________________
--Wolfgang


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.