[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-1615) GROUP BY entity does not work
Rafael Santini (JIRA)
noreply at atlassian.com
Wed Jul 1 10:39:18 EDT 2009
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1615?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33508#action_33508 ]
Rafael Santini commented on HHH-1615:
-------------------------------------
I also ran into this problem with SQL Server. With MySQL the same query works.
HQL:
select count(emprestimo.exemplar.obra), emprestimo.exemplar.obra from Emprestimo emprestimo where emprestimo.data between ? and ? group by emprestimo.exemplar.obra order by count(emprestimo.exemplar.obra) desc
SQL generated:
select count(exemplar1_.id_obra) as col_0_0_, exemplar1_.id_obra as col_1_0_, obra2_.id as id157_, obra2_.mfn as mfn157_, obra2_.titulo as titulo157_, obra2_.localizacao as localiza4_157_, obra2_.id_idioma as id5_157_, obra2_.id_tipo_obra as id6_157_, obra2_.id_categoria_obra as id7_157_, obra2_.id_area_obra as id8_157_, obra2_.id_base as id9_157_ from bs_emp_mov_emprestimo emprestimo0_, bs_emp_ace_exemplar exemplar1_, bs_emp_ace_obra obra2_ where emprestimo0_.id_exemplar=exemplar1_.id and exemplar1_.id_obra=obra2_.id and (emprestimo0_.data between ? and ?) group by exemplar1_.id_obra order by count(exemplar1_.id_obra) desc
Error:
A coluna 'bs_emp_ace_obra.ID' é inválida na lista de seleção porque não está contida em uma função agregada nem na cláusula GROUP BY.
> GROUP BY entity does not work
> -----------------------------
>
> Key: HHH-1615
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1615
> Project: Hibernate Core
> Issue Type: Improvement
> Components: query-hql
> Affects Versions: 3.2.5
> Environment: PostgreSQL 8.1.3, Hibernate 3.1.3
> Reporter: Xavier Bugaud
> Assignee: Anthony Patricio
> Priority: Critical
> Attachments: group-by-discriminator.patch, hibernate-group-by.diff
>
>
> The query : "select cat, count(*) from Cat cat group by cat" does not work.
> ERROR: column "xxxx" must appear in the GROUP BY clause or be used in an aggregate function
> See :
> - http://forum.hibernate.org/viewtopic.php?t=953716
> - http://jira.nhibernate.org/browse/NH-528
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list