-->
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: Criteria having and group by?
PostPosted: Thu Apr 13, 2006 6:39 am 
Newbie

Joined: Sat Apr 08, 2006 8:15 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1

Hi,

I have a class Reservation with a list of Payment objects:

Code:
class Reservation{
...
List<Payment> payments
...
List getPayments(){
...
}

}

class Payment{
  float amount;
}


both annotated/mapped in hibernate.

what I need is to get a report query which gives me all Reservations where the sum of the amounts of payments of that Reservation are greater than 0 (or another amount).
Actually it's a report query where I have to filter dynamically on other fileds of Reservation as well, thus I want to use Criteria.

a sql query which would give me the expected result would be something like

Code:
select reservation.* from reservation join payment on reservation.id = payment.reservation_id group by reservation.id having sum(payment.amount) > 3


other where clauses are needed to filter on other fields of reservation (customer, date, ..)

I have read through documentation but couldnt find a way to chieve this via Criteria, can you help me because I am quite stuck.

Thanks in advance

Francesco


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.