-->
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.  [ 9 posts ] 
Author Message
 Post subject: group by entity does not work
PostPosted: Thu Jan 05, 2006 7:06 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
I'm trying to do a simple HQL query that selects an aggregate expression and an entity. I tried something functionally equivalent to the example shown in the documentation (section 11.5):

Quote:
select cat, count( elements(cat.kittens) )
from eg.Cat cat group by cat


This does not work in NHibernate 1.0.1. I get an ADO exception complaining that all of the columns in the underlying table for the selected entity do not appear in the SQL "group by" clause. Apparently NHibernate is supposed to build the SQL "group by" clause appropriately, but doesn't do so ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 9:15 am 
Beginner
Beginner

Joined: Tue Sep 23, 2003 5:00 pm
Posts: 40
I guess it should be :
Code:
group by cat.x
where x is an attribute of cat, eg group by
Code:
cat.color

sylvain_2020


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 5:51 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
According to examples in the documentation, I shouldn't have to do that. In a typical query where I want to select an aggregate expression, I'll also be selecting 3 or 4 entities, each of which has 15-20 properties. I shouldn't have to worry about what those 45-80 properties are, and shouldn't have to name each one in the HQL query. Anyway, I think the HQL parser would complain because you're not explicitly selecting the properties, you're selecting entities.

I can't tell from the documentation if grouping by entities is supported or not. It's shown in 3 different examples in chapter 11, yet in the section on "GROUP BY", it says you can group by any property. It doesn't actually say you can group by entities. So, it appears to be either

1. Several examples in Chapter 11 are invalid; you can't really group by entities.

2. Section 11.10 "The group by clause" forgot to mention that you can group by entities; it actually works in Hibernate, but is broken in NHibernate.

I'm hoping it's #2, because I really need this feature to work ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 06, 2006 6:09 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Apparently this was broken in Hibernate 2.1, but was intended to work. I don't know if it was ever fixed or not. If a fix exists, can the fix be ported to NHibernate?

Here is a related related topic from the Hibernate forum:

http://forum.hibernate.org/viewtopic.php?t=950514


Top
 Profile  
 
 Post subject: Is there any new on this issue?
PostPosted: Wed Jan 25, 2006 4:14 am 
Beginner
Beginner

Joined: Mon Dec 19, 2005 4:13 am
Posts: 27
Location: Prague, Czech Republic
I alsou found this bug frustrating. Can it be fixed please?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 3:27 am 
Beginner
Beginner

Joined: Wed Jun 08, 2005 4:59 pm
Posts: 27
Another plea for a fix (seems simple enough, enumerate all properties of obj in the order by instead of just the id when selecting obj).

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 5:16 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Please report it in JIRA and vote for it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 2:24 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
I reported it in JIRA about a week or more ago.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 2:26 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
http://jira.nhibernate.org/browse/NH-528


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