Hi
Hibernate version: 3
For simplicity i have two entities - Opertor and OperatorSummary with the following mappings:
Mapping documents:
Code:
<class name="Operator" table="OPERATORS" dynamic-update="true" lazy="true" schema="DBO">
<id name="operatorid" unsaved-value="null" type="long" column="operatorid" >
<generator class="sequence">
<param name="sequence">SQ_OPERATORS</param>
</generator>
</id>
<version name="version" type="long" column="VERSION" unsaved-value="null" />
<property name="operatorcode" type="long" column="OPERATORCODE" not-null="true" unique="true" />
<property name="operatorname" type="string" column="OPERATORNAME" />
</class>
and
Code:
<class name="OperatorSummary" table="OPERATORSUMMARY" dynamic-update="true" schema="DBO">
<composite-id>
<key-many-to-one name="operator" class="Operator" column="OPERATORID" />
<key-property name="actiondate" type="timestamp" column="ACTIONDATE" />
</composite-id>
<property name="summarydata" type="double" column="SUMMARYDATA" />
</class>
In business-model: each operator has daily statistic of some process.
I want to get total operator's statistic for time interval. In result of this report i need oject with Operator-entity and total value.
[code]
select oper, sum(opersum.summarydata) from OperatorSummary os join fetch opersum.operator oper group by o
[/oper]
but i get SQL-error. I can't use fields in select that doesn't appear in group by clause.
Any suggestion?
And one more thing. I'm planing to use new object to keep (Operator, summary) pairs. Like
[code]
select new DaySummary(oper, sum(opersum.summarydata)) from OperatorSummary os join fetch opersum.operator oper group by o
[/oper]
is this possible?
Thanks.