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