Here is how it works:
(1) If no one else modified the data, the version should be the same. There shouldn't be an optimistic locking exception.
(2) If someone modified the record, the 'old' version number should cause an optimistic locking exception.
My goal is to use hidden field values rather than store some objects or hibernate session to implement optimistic locking in a Struts type web application. Is there any way to do it other than using httpSession to store disconnected hibernate session or objects?
mchyzer wrote:
This doesnt really make sense.
If you are getting a row from the DB, and setting the version, then you arent going to persist that version... which is weird. Might as well just instantiate a new object, set the id, and the version, and the other fields, and persist that... right?
I think the bottom line of why, is hibernate is trying to solve more problems than it creates. If it doesnt trust the bean, then it can know when people change the version field, which is not common and is a cause for error.
Chris