-->
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: get the sum in collection ???
PostPosted: Fri Dec 19, 2003 12:42 am 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
Hello,


how can query the sum of a Set ??

For example?

Code:
class Man {

   public Set getCars() {
      return cars;
   }
}

class Car {

   public double getPrice() {
      return price;
   }
}


how can I get the sum(cars.price) for the Man ???


Eric


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 8:37 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Code:
Double result = (Double)sess.createQuery(
    "select sum(car.price) from Man m " +
    "join m.cars car where .....").uniqueResult();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 19, 2003 10:46 am 
Regular
Regular

Joined: Fri Sep 05, 2003 12:01 am
Posts: 80
Location: Bogot
another idea : have you had a look at the formula property?

Not sure myself if it would work... but if it does, drop a line! ;-)

_________________
Mauricio Hern


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.