Originally posted by Ali Pope:
Automatic versioning is a simple technique for assuring data integrity.
Consider the following: clients A and B load the same record R. After a time A commits back R with data changed, and after a while B commits too .. changing data of R - but not from the state of R after commit A.
Automatic versioning does the following: a field is used to version the row data. In the above scenario A and B obtain the record R with version t. After the commit A the version is changed, so when B tries to commit the check upon the version fails.
This is somehow similar to a simple one using timestamps - which is not recommended.
./pope
PS: I hope I was able to express my thoughts :-).
Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/193239415X/ref=jranch-20" target="_blank" rel="nofollow">Hibernate in Action</a>
Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/193239415X/ref=jranch-20" target="_blank" rel="nofollow">Hibernate in Action</a>
Originally posted by Gavin King:
Hibernate checks the JDBC row count, and throws a StaleObjectStateException if no rows were updated
Originally posted by Ali Pope:
1. an exception is thrown upon saveOrUpdate(), update() call: StaleObjectStateException.
2.You have the possibility to describe the column used for versioning. Please check Chapter 10.4 for details on optimistic concurrency control and for details on mapping: Chapter 5.1 (5.1.7 version).
./pope
Originally posted by Ogi Kavazovic:
The part that's not clear is who increments the version here?
Originally posted by Mat Robinson:
Adding to this point, is there a way or could there be a way to not update the existing version but to always insert new rows with the new version number. Thus automatically generating an auditable database.
I gotta keep learning...
Manish fico wrote:Steve,
does any of your entities in HQL follow inheritance? If thats the case, hibernate will try to sync the versions of the parent and child even in read operation.
Regards,
Manish
I gotta keep learning...
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |