-->
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.  [ 3 posts ] 
Author Message
 Post subject: Aggressive version column incrementing, even when not dirty
PostPosted: Tue Nov 01, 2005 12:30 am 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
In hibernate 3.1 + EJB3 annotations, I'm using a hibernate managed version column (@Version). The act of reading an object (but not modifying it), causes its version column to be incremented at every single flush, even when the object is not dirty.

For example, I have an object type that is specifically designed to just hold data, and will perhaps be updated once every few months. In the course of a few runs on my application it ends up with a verson of around 90, when I've made no changes to the object whatsoever...

What would cause this aggressive version updating, and what can I do to prevent it?

Thanks,

Ryan

[/list]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 5:49 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Probably your getter or setter do something that change the data.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 02, 2005 1:52 pm 
Beginner
Beginner

Joined: Wed Oct 01, 2003 3:47 pm
Posts: 44
I learned my lesson. I had a custom user type whose equals method did everything but this very important line:

if (x == null && y==null) return false;

Thus, null properties were being counted as dirty.

All fixed!


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