Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate 3.2.5
Name and version of the database you are using:
MySQL, version: 5.0.45-community-nt
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="test">
<class name="Test">
<id name="ID" type="long" access="field">
<generator class="identity" />
</id>
<property name="category" type="int" access="property"
not-null="true" />
<component name="c1" class="Component" lazy="false">
<property name="field1" type="long" access="property"
column="c1_field1" not-null="true" />
</component>
<component name="c2" class="Component" lazy="false">
<property name="field1" type="long" access="property"
column="c2_field1" not-null="true" />
</component>
</class>
</hibernate-mapping>
What is the correct HQL to allow ResultTranformer to create an entity if I need to aggregate the value in field1 and field2?
I've tried
Code:
SELECT t.ID as ID, t.category as category, sum(t.c1.field1) as t.c1.field1, sum(t.c2.field1) as t.c2.field1
FROM Test as t
GROUP BY t.category
and
Code:
SELECT t.ID as ID, t.category as category, sum(t.c1.field1) as c1.field1, sum(t.c2.field1) as c2.field1
FROM Test as t
GROUP BY t.category
but none of it works, any idea how to get around this?