-->
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: Is it possible to use HQL for fields not stored in the Datab
PostPosted: Mon Nov 28, 2005 9:31 pm 
Newbie

Joined: Mon Nov 28, 2005 12:00 pm
Posts: 2
Is it possible to use HQL for fields not stored in the Database?

For instance, let's say my object has a method - a getter - which instead of returning a property, runs some calculations. Is there anyway I can use HQL on this method?

Now, I realize that there would be tremendous performance costs for this. How is this normally handled? Can I write the method in SQL - instead of Java - and then have Hibernate use the SQL formula to query? How do I this for subclasses (will Hibernate automatically use that classes SQL forumla)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:03 am 
Regular
Regular

Joined: Thu Oct 27, 2005 8:06 am
Posts: 55
Location: München, Germany
As far as I understand the definition of HQL, it only allows to use properties, which are the items defined in the mapping files.

However, you may define derived properties. So if you can express your calculation in an SQL formula, then define a derived property for your purpose. As the calculation can be included in any SQL search that Hibernate issues, your performance qualms are solved.


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.