-->
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: calculated property mapping
PostPosted: Tue Jun 15, 2010 3:02 pm 
Newbie

Joined: Sat May 01, 2010 1:27 pm
Posts: 2
Hi,

I have a class with a calculated field:

Code:
class MyClass {
  ...
  private Integer total;

  public Integer getTotal() {
    ... some calculations...
    return v;
  }
  ...
}


"total" is not a database field. It's just a calculated property.
Can I use this property in a Hibernate query like this:

Code:
select m.total from MyClass m


And if this is possible, how can I map the property in MyClass.hbm.xml file ?

Thanks a lot.


Top
 Profile  
 
 Post subject: Re: calculated property mapping
PostPosted: Wed Jun 16, 2010 3:05 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
If the calculations can be done by the database you can map it using a formula: <property name="total" formula="....." >.


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.