-->
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 expressions in select
PostPosted: Fri Nov 28, 2003 7:03 am 
Beginner
Beginner

Joined: Fri Nov 28, 2003 6:57 am
Posts: 20
Hi,

I have a table with three int fields (a,b,c) and want to get the sum of them in a select this way:
select a+b+c as result from table

It seems that you cannot use expressions in the select, but only in the where clause. Is there a possibility to do such a select?

TIA,

Thorsten


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2003 8:31 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Either :
- do your own user type (section 4.2.4)
- add a unmapped getter that compute
- "select new MyObject(a, b, c)" where MyObject will not be a persisted object

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 29, 2003 2:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
epbernard has great suggestions. The answer is no you cannot do expressions in the select clause of HQL. This will be addressed in the future as a new parser is being prototyped which makes this a little easier to do.
BTW: You can not have literals either.


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.