-->
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.  [ 7 posts ] 
Author Message
 Post subject: arithmetic expressions in hql select clause
PostPosted: Mon Apr 04, 2005 7:54 pm 
Regular
Regular

Joined: Thu Aug 26, 2004 9:23 pm
Posts: 71
Is it not possible do use any arithmetic expressions in the select clause of hql? Here is an example from my current project where this would be useful:

Code:
select sum(transaction.quantity * transaction.cost) from Transaction transaction


Mike


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 8:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Not in hibernate 2.x but in the future yes at some point for Hibernate 3.x . This issue is one of the reasons we went to a AST based parser. Makes this easier to support.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 8:06 pm 
Regular
Regular

Joined: Thu Aug 26, 2004 9:23 pm
Posts: 71
Thanks for the quick reply David. Do you know if there is currently an issue in JIRA for arithmetic in the select clause? I noticed a few days ago Gavin was soliciting enhancements for the new AST parser.

Mike


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 8:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Its a given that it will be supported but I suppose it should be documented anyway. I have not kept upto date with what is going on with the parser or requests for it in JIRA. You should have a look. I do know some work has been done but I don't know what state it is in at this point.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 8:17 pm 
Regular
Regular

Joined: Thu Aug 26, 2004 9:23 pm
Posts: 71
One last question. I'm kind of new to Hibernate, do you know if this is possible to use expressions in select clause if I use Criteria?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 8:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
In general the Criteria API represents a subset of HQLs functionality (though its getting much closer now in Hibernate 3.x).

See this for more info [H3]
http://www.hibernate.org/hib_docs/v3/reference/en/html/querycriteria.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 05, 2005 6:27 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Mike,
For you example try next (for now) :

- create formula property for transaction.quantity * transaction.cost (for instance property qty)

- now query is

select sum(qty) ...

regards


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