-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: HOW-TO: programatic lazy loading
PostPosted: Tue Mar 27, 2007 12:03 am 
Newbie

Joined: Fri Nov 18, 2005 1:01 pm
Posts: 18
Location: Delft, the Netherlands
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,

_________________
Joost Schouten
JS Portal


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.