-->
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.  [ 3 posts ] 
Author Message
 Post subject: HAVING using Criteria
PostPosted: Thu Mar 22, 2007 10:54 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 1:43 pm
Posts: 22
Is it possible to generate HAVING using Criteria API? Something like this

Code:
Select ShopperId,
Sum(Total) as STotal,
Min(Date) as MinDate
From Orders
Group by ShopperId,
HAVING Sum(Total) < 10000
And Min(Date) > '2007-01-01'


Thanks in advance, Tom


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 1:07 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Having is not yet available in the Criteria API (see Java Persistence with Hibernate book, page 678).

Without the having part, it would be something like:
Code:
getSession().createCriteria(Orders.class).setProjection(Projections.projectionList().
            add(Projections.sum("total")).
            add(Projections.min("date")));


Sorry :)

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 27, 2007 3:55 pm 
Beginner
Beginner

Joined: Mon Apr 24, 2006 1:43 pm
Posts: 22
I thought so... too bad. Thanks for the reply

Tom


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

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.