-->
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: Dirty checking
PostPosted: Wed Mar 02, 2005 9:35 am 
Newbie

Joined: Thu Feb 24, 2005 3:51 pm
Posts: 9
Location: Montevideo, Uruguay
I want to check if a detached persistent instance has been changed since it was loaded from the database. Can Hibernate do this for me? or do I have to load another instance from the database and perform a manual field-by-field comparison in memory?

I tried using Session.lock with LockMode.NONE and LockMode.READ and passing it the modified transient instance.
I expected it to throw an HibernateException (since the instance I'm trying to lock has been modified) but it didn't.

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 7:16 pm 
Beginner
Beginner

Joined: Fri May 21, 2004 12:21 pm
Posts: 22
Location: Sacramento CA, USA
You can use optimistic locking using a version field in your table. Read the hibernate reference manual about this. They have explained it in detail there.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 09, 2005 8:21 pm 
Newbie

Joined: Thu Feb 24, 2005 3:51 pm
Posts: 9
Location: Montevideo, Uruguay
That would work if wanted to check if someone else changed the database since I loaded my objects. However, what I want to do is check if the objects have changed in memory (the version number isn't increased until I perform an update and then it would be too late)


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.