-->
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.  [ 4 posts ] 
Author Message
 Post subject: Group by doubts
PostPosted: Tue Aug 10, 2004 2:39 pm 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Hibernate version:
2.1.4

If I have two entities amostra and Amostraexame, where Amostra has a set of amostraexame. I want to group by amostra object:

Code:
select amostra,count(ams) from Amostra as amostra join amostra.AmostraexameSet as ams
group by amostra


Is it legal ? I'm getting an error becouse the group by "entity" result in a group by only in the primary key.

Quote:
org.postgresql.util.PSQLException: ERROR: column "amostra0_.dscamostra" must appear in the GROUP BY clause or be used in an aggregate function


query dumped (the group by is the important part):

Code:
select amostra0_.chvamostra as chvamostra, amostra0_.dscamostra as dscamostra, amostra0_.dtrcbamostra as dtrcbamo3_, amostra0_.dscreduz as dscreduz, amostra0_.qtdamostra as qtdamostra, amostra0_.chvsite as chvsite, amostra0_.chvmaterial as chvmater7_, amostra0_.chvestimulo as chvestim8_, amostra0_.chvrequisicao as chvrequi9_, amostra0_.chvamostra as x0_0_, count(amostraexa1_.chvexmam) as x1_0_
from labsystem.amostra amostra0_ inner join labsystem.amostraexame amostraexa1_ on amostra0_.chvamostra=amostraexa1_.chvamostra group by  amostra0_.chvamostra


well , by reading the reference guide query:

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


I suppoused it's legal construction. I need to do something like this too:

Code:
select amostra, amd.repeticao
from Amostra as amostra join amostra.AmostraexameSet as ams
group by amostra,amd.repeticao


Is it possible ?
Thanks for your efforts

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 10, 2004 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Need to detail all the fields in the group by. Currently not automated for you.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 9:18 am 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Thanks man !

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 3:33 am 
Newbie

Joined: Wed Jan 05, 2005 2:28 pm
Posts: 14
Location: Germany, Munich
david wrote:
Need to detail all the fields in the group by. Currently not automated for you.


This seems still valid for Hibernate 3.0.5 - is it planned to automate that?


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