-->
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: using aggregate function
PostPosted: Thu Sep 13, 2007 2:35 pm 
Newbie

Joined: Wed Aug 01, 2007 4:00 am
Posts: 8
Hello,

I am using hibernate 3

I have a table which contains

id Integer
product_name Varchar(50)
category_id Integer
stock Integer
rate decimal

I need to get the product which has max(rate). I know I can use the
hibernatetemplate.find( query ) to get it. But I don't know how to design
a Java class for this purpose? I mean the getter and setter methods
for the max column.

Somebody help me please.

Thank you.

Sudheer Palaparambil


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 14, 2007 3:52 am 
Senior
Senior

Joined: Thu May 17, 2007 2:31 am
Posts: 194
Location: Sri Lanka
Hi

You don't want to add getter/setters for max column. only for

id Integer
product_name Varchar(50)
category_id Integer
stock Integer
rate decimal


you can get it several wats.

List list=session.createSQLQuery("select * from TableName where rate=(select max(rate) from TableName)").addEntity(ClassName.class).list();


Amila

(Don't forget to rate if helps)


Last edited by amila733 on Mon Sep 17, 2007 1:27 am, edited 2 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 15, 2007 10:00 pm 
Newbie

Joined: Wed Jun 21, 2006 2:25 pm
Posts: 15
from product where rate = (select max(rate) from product)

Hope this helps

anand raman


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.