Issue Details (XML | Word | Printable)

Key: HHH-1865
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Minor Minor
Assignee: Unassigned
Reporter: Nestor Boscán
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Hibernate Core

Group by does not expand columns

Created: 28/Jun/06 11:33 AM   Updated: 17/Sep/06 01:24 PM   Resolved: 17/Sep/06 01:24 PM
Component/s: query-hql
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment:
Windows XP
JDeveloper 10.1.2.1
Issue Links:
Duplicate
 

Bug Testcase Reminder (view):
REMINDER: Bug reports should generally be accompanied by a test case
Participants: Nestor Boscán


 Description  « Hide

Hi

I need to use Hibernate 3.1.3 to create a query that returns an object and a aggregate value like this:

select max (t.test_date), t from TestTo t.

Because I have an aggregate function I have to define the GROUP BY clause:

select max (t.test_date), t from TestTo t group by t

But I get an error:

ORA-00979: not a GROUP BY expression

The generated SQL is:

select max(testto0_.test_date) as col_0_0_,
testto0_.test_value as col_1_0_,
testto0_.test_value as test1_0_,
testto0_.test_date as test2_0_
from TEST testto0_
group by testto0_.test_value

It seems that Hibernate is expanding all columns of the TestTo class in the SELECT statement but not in the GROUP BY statement.

The TestTo class:

public class TestTo
{
private int value;
private Date date;

public TestTo()
{
}

public int getValue()
{
return value;
}

public void setValue(int value)
{
this.value = value;
}

public Date getDate()
{
return date;
}

public void setDate(Date date)
{
this.date = date;
}
}

The Mapping File:

<hibernate-mapping>
<class name="mypackage.TestTo" table="TEST">
<id name="value" column="test_value">
<generator class="sequence">
<param name="sequence">seq_test</param>
</generator>
</id>
<property name="date" column="test_date"/>
</class>
</hibernate-mapping>



There are no comments yet on this issue.