-->
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.  [ 5 posts ] 
Author Message
 Post subject: Concurrent-update-check using a hash
PostPosted: Wed Sep 03, 2003 10:56 am 
Newbie

Joined: Wed Sep 03, 2003 10:40 am
Posts: 6
Can hibernate perform a concurrent-update-check (stale object check) without version field, but instead using a hash? For example:

Step 1: Load an object from db
Step 2: disconnected (perform a hash of the object's original data)
Step 3: user makes some changes to the object
Step 4: reconnect
Step 5: session.update (re-read object from database and compare with hash)

If the db data's hash doesn't match the object's before-edit hash, then throw a StaleObjectStateException.

_________________
Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 11:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You can acheive this using the "application version checking". Check out the docs on this at http://www.hibernate.org/hib_docs/reference/html/transactions.html#transactions-s3-3


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 8:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I am implementing more options along these kinds of lines in Hibernate 2.1.


One thing that Hibernate 2.1 can *already* do is perform a check against the current database state when update() is called. This eliminates the requirement for "application version checking" in some cases. (But not in yours.)

We will also soon support optimistic locking on dirty-fields or all-fields.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2003 1:16 pm 
Newbie

Joined: Wed Sep 03, 2003 10:40 am
Posts: 6
One more note as a point of interest. I believe this model - concurrent-update (stomp) checking without a version field - is the default model in ADO.NET.

_________________
Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2003 3:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
FYI, we ran into huge problems with this in Castor against Oracle. The issue has to do with String and VARCHAR columns, and is particularly problematic in web environments. The issue is caused by the fact that Oracle replaces and empty varchar values it finds on INSERT/UPDATE to be null; however, it does not do the same thing during querying.

So consider a Person object with a title field which is not required. Setting the title field on a new person instance to an empty string and then persisting that instance would leave the state as title="" in the java entity, but title=null in the DB.

Later, that person is loaded and the name is updated and person persisted again. The concurrent update check fails because "" is not equal to null according to Oracle (even though they thought it was during the persist).

This is an issue up through 8i. God, I hope they fixed that in 9i.

Just something to consider...


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