-->
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 sum() twice over Entity objects using create criteria
PostPosted: Thu Jan 12, 2012 8:31 pm 
Newbie

Joined: Tue Jan 10, 2012 8:29 pm
Posts: 6
Hi,
I have 12 Summary tables(Entities) one for each month txnJan, txnFeb,..and so on.. it has fields like date, transactionCount, location.
Now I have been given a date range as input, I want to get a list of all locations with their transactionCount using Hibernate query.
So,
1) I get months in the range and get the Entity Object List from that..
2) for each Entity Object I do a sum(transactionCount) group by location
3) do a left join of all individual Months and sum (transactionCount) group by Location on All Months..
So I am able to get the locations and sum(transactionCount) for each month in the range
How Do I combine all the individual Month Results
My Code is currently something like this:
Code:
//  sTblList- List of Summary Tables (Entity Objects) in given date range
sTblList.each{
         def OnemonthMap=it.createCriteria().get {   
            eq('resource',resourceInstance)
            between('date', fromDate, toDate)       
            projections { 
            sum(sumCol)
            groupProperty(groupCol)     
                }                 
            }     
           
        return sumMap //currently empty -should have combine location and counts for all months
    }


please suggest If there is another way to Implement than Criteria API which is more simple .
Thanks in Advance


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.