-->
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: Need to persist a field that was previously derived
PostPosted: Wed Jul 11, 2007 1:30 pm 
Newbie

Joined: Fri Aug 04, 2006 6:09 am
Posts: 18
Hi,

I have a contract domain object. The contract object contains SETs of contract Line items and other various properties that my app uses.

At present, calculating the contract cost is done via a call to a getTotalContractCost() method. This is transient method. The method checks the dependent objects as necessary. This works well.

Now the users want to store the contract cost in the db.

I need advice on how to accomplish this.

What i would like to do (i think) is that every time Hibernate detects that the object is dirty to also update the contract cost field. That way i do not have to worry about what fields were changed in the contract.

Is this possible?

Thanks

R


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 5:11 pm 
Newbie

Joined: Thu Nov 09, 2006 9:42 pm
Posts: 13
If you are using JPA annotations you should be able to hang the annotations off the accessor performing the business logic. There should also be a way to configure property v/s accessor usage in Hibernate's HBM files if you are using that.

This will not track the dirty state of the object for you, but will allow you to updated the value in the database with a call to persist/merge/saveOrupdate when the state changes. There is no way to have Hibernate monitor the dirty status of an object as far as I know.

--
Tim


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.