-->
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: Strange dirty checking
PostPosted: Thu Sep 28, 2006 11:10 am 
Newbie

Joined: Thu Sep 28, 2006 9:22 am
Posts: 1
I have a strange problem with hibernates dirty checking.
In my entitybean ex product i have a getmethod for ex price like

getPrice(){
return this.price*2;
}

Then hibernate thinks this object is dirty and updates the object with the result of this.price*2 but the value of this.price is never changed. All I do is to call the getmethod which have a calculation on the price value before returning. Anyone have simular experience and a workaround for this ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 8:14 pm 
Newbie

Joined: Mon Mar 15, 2004 5:48 am
Posts: 9
This occurs because you have your hibernate mapping using the default property access. It assumes that getPrice() will return the value that it loaded for the price property from the database.

Either change the name of your method to something that doesn't imply it is getting the unaltered price, or change your hibernate mapping file to use field level access instead of the default property access.

e.g.
<property name="price" access="field">


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.