From: <no...@at...> - 2006-06-28 16:35:18
|
Group by does not expand columns -------------------------------- Key: HHH-1865 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH= -1865 Project: Hibernate3 Type: Bug Components: query-hql =20 Environment: Windows XP JDeveloper 10.1.2.1 Reporter: Nestor Bosc=C3=A1n Priority: Minor Hi=20 I need to use Hibernate 3.1.3 to create a query that returns an object and = a aggregate value like this:=20 select max (t.test_date), t from TestTo t.=20 Because I have an aggregate function I have to define the GROUP BY clause:= =20 select max (t.test_date), t from TestTo t group by t=20 But I get an error:=20 ORA-00979: not a GROUP BY expression=20 The generated SQL is:=20 select max(testto0_.test_date) as col_0_0_,=20 testto0_.test_value as col_1_0_,=20 testto0_.test_value as test1_0_,=20 testto0_.test_date as test2_0_=20 from TEST testto0_=20 group by testto0_.test_value=20 It seems that Hibernate is expanding all columns of the TestTo class in the= SELECT statement but not in the GROUP BY statement.=20 The TestTo class:=20 public class TestTo=20 {=20 private int value;=20 private Date date;=20 public TestTo()=20 {=20 }=20 public int getValue()=20 {=20 return value;=20 }=20 public void setValue(int value)=20 {=20 this.value =3D value;=20 }=20 public Date getDate()=20 {=20 return date;=20 }=20 public void setDate(Date date)=20 {=20 this.date =3D date;=20 }=20 }=20 The Mapping File:=20 <hibernate-mapping>=20 <class name=3D"mypackage.TestTo" table=3D"TEST">=20 <id name=3D"value" column=3D"test_value">=20 <generator class=3D"sequence">=20 <param name=3D"sequence">seq_test</param>=20 </generator>=20 </id>=20 <property name=3D"date" column=3D"test_date"/>=20 </class>=20 </hibernate-mapping> --=20 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 |