-->
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.  [ 5 posts ] 
Author Message
 Post subject: Expressions in the SELECT clause
PostPosted: Tue Aug 10, 2004 9:09 pm 
Newbie

Joined: Mon Feb 09, 2004 6:07 pm
Posts: 7
I have read the documentation, as well as some previous posts related to this entry...i.e. being able to use expressions in the select clause.

Basically, how can I do something like this (I am just giving a simple example...the actual query involves lot of tables and joins):

select foo.field1, foo.field2, foo.field1*12+foo.field2 as total
from com.abc.xyz.hibernate.Foo as foo

From what I have read, it is not possible to use expressions in the select clause. This feature may be implemented in some future 3.x release, but I would like to know the recommended approach to overcome this limitation. How do people circumvent this limitation in HQL?

Thanks in advance.

Regards,

Shireesh Thanneru


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 10:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
A mapped formula would work.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 10:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Or do the calculation in Java.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:26 pm 
Newbie

Joined: Mon Feb 09, 2004 6:07 pm
Posts: 7
steve wrote:
A mapped formula would work.


Worked like a charm. Thanks a lot! I appreciate it very much.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 11, 2004 2:37 pm 
Newbie

Joined: Mon Feb 09, 2004 6:07 pm
Posts: 7
michael wrote:
Or do the calculation in Java.

Thanks for your reply. Yeah, I know we can do it in Java. But if we do it in Java, then we cannot use the <b>order by</b> clause on this calculated value. I think I can even use the <b>order by</b> clause with the mapped formulas. If not for the order by clause, I think even this solution will work out well (unless if we really want to order the results in Java).


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