Hi,
After quite a search I have not found a way to map a collection generated by a query using the GROUP BY clause and populating one of the values with a sum().
The query is fairly straight forward and works fine in SQL and HQL. For this reason I want to load the collection programatically. I can do this with the
Code:
public boolean onLoad(Object entity,Serializable id,Object[] state,String[] propertyNames,Type[] types){}
from the EmptyInterceptor
But I prefer lazy fetching becuse of performance reasons. How do I go about setting this up. Ho can I tell hibernate to populate my collection when it is called by it's getter getSummedCredit() in my User bean?
My bean getter and setter:Code:
public Set getSummedCredit(){
return this.summedCredit;
}
public void setSummedCredit(Set summedCredit) {
this.summedCredit = summedCredit;
}
My SQL:Code:
SELECT sum(sc.amount) as amount sc.currency FROM transactions sc WHERE sc.receiver=:id AND sc.reservation=0 GROUP BY sc.receiver, sc.currency
Thank you very much for your help.
Best regards,