-->
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.  [ 2 posts ] 
Author Message
 Post subject: Query problem ?
PostPosted: Thu Dec 18, 2003 11:41 pm 
Regular
Regular

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

Code:
class Man {

   Set cars;

   public Set getCars() {
      return cars;
   }
}


class Car {
   Man owner;
   double price;

   public double getPrice() {
      return price;
   }

   public Man getOwner() {
      return owner;
   }
}


I want to retrieve the sum of the price that a man owns.

For example, a man has three cars, and I want to get the total price of that three cars. How can define a query for that?




Bets regards,
Eric


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

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
As per my other post:

Code:
Double result = (Double)sess.createQuery(
    "select sum(car.price) from Man m " +
    "join m.cars car where .....").uniqueResult();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.