Dear Batmat,
Thank ytou for your reply. I think I'm looking for something like the formula or collection mapping's where clause. I tried the folowing, which doesn't work as the order by clause is injected in the where clause and not understood. Nor would this sum the amount like I would want to.
Code:
<set
name="summedReservedCredit"
lazy="true"
inverse="true"
cascade="none"
where="GROUP BY receiver,currency"
>
<key>
<column name="receiver" />
</key>
<one-to-many
class="com.jsportal.projectportal.portalBeans.FinancialTransaction"
/>
</set>
I looked into using named queries like:
Code:
<set
name="summedCredit"
lazy="true"
inverse="true"
cascade="none"
>
<key/>
<one-to-many class="FinancialTransaction"/>
<loader query-ref="summedCreditSQL"/>
</set>
<sql-query name="summedCreditSQL">
<load-collection alias="sc" role="User.summedCredit"/>
SELECT sc.* FROM transactions sc WHERE sc.receiver=:id AND sc.reservation=0 GROUP BY sc.receiver, sc.currency, sc.type
</sql-query>
This does get some result, but still doesn't sum my amount. What other tools are there to acomplish my result. Is there a way to have hibernate simply populate my User bean with a resultset and have my bean handle it on setSummedCreditRS(ResultSet)?
Thank you,
Joost