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: Regarding Froup By Having clause in Criteria Queries
PostPosted: Wed Apr 04, 2007 12:35 am 
Newbie

Joined: Wed Apr 04, 2007 12:17 am
Posts: 1
Location: Hyderabad
Hi All !

I'm Krishna. I'm working with Hibernate Criteria queries. I'm writing Group By query. I dont know how to apply Restrictions for Gruop By clause.

Anyone know how to write having clause in Criteria Group By Projections.

My code is like this:

List statusList1=session.createCriteria(Division.class,"divn")
.createCriteria("companyProfiles","company")
.add(Restrictions.eq("companyId", companyId))
.createCriteria("divn.divisionCostCenters", "divisionCostCenter")
.createCriteria("costCenter","cc")
.createCriteria("expenseReports", "report")
.createCriteria("expenseReportStatuses", "ers")
.add(Restrictions.between("modifiedDate",stDate,edDate))
.setProjection( Projections.distinct(Projections.projectionList()
.add(Projections.groupProperty("divn.divisionId"))
.add(Projections.groupProperty("report.costCenter.costCenterId"))
.add(Projections.property("divn.divisionName"))
.add(Projections.property("cc.costCenterName"))
.add(Projections.count("report.currentStatus.statusId").as("1"))
.add(Projections.count("report.currentStatus.statusId").as("2"))
.add(Projections.count("report.currentStatus.statusId").as("3")) ))


Here I have differnt statusIds sach as 1,2,3.
I want to display satusId with 1 in 1 column, 2 in another column and so on.

I wrote till here, but couldn't find the solution.

Can anybody suggest me a way please ?

Thanking you,

Krishna
[/b]

_________________
Ch. Krishna Reddy


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.