Hibernate version: 1.0.2.0
Hello folks,
I've come across a behavior I didn't unexpected and I wonder if it's a bug - my version number on the stale object remains incremented after the rollback triggered by the StaleObjectException.
here's the sequence (in a web-app):
-first post
a1. load the object and place it in the viewstate
-second post
b1. in another window load 2nd copy
-3rd post
c1. update the object from UI
c2. open transaction
c3. try to saveOrUpdate
c4. commit
- it's all nice and saved, and the version in db and the 1st copy incremented
-4th post
d1. update the 2nd copy from UI
d2. open transaction
d3. try to saveOrUpdate (the 2nd copy)
d4. catch and rollback
- at this point the database is intact, but the 2nd copy's version is updated (and incidentally matches the version in DB)
The version mapping:
Code:
<version name="Version" column="version" type="Int32"/>
It doesn't seem... natural. And the real problem is, the 2nd copy (with now updated version) is automaticaly serialized back into the viewstate and subsequent attempt at save succedes when it shouldn't!
Any thoughts?
TIA,
ET