Can some body explain if this is the expected behaviour,
My application uses 'version' for optimistic locking and following is used to specify the version property
@hibernate.version column="version_id" type="long"
I am reading a record for update (displayed on GUI). During this update process (before making final update call) some other process (may be external) comes along and updates the same record setting version to a differnet value( +1). I expect Hibernate to throw StaleDataException when the GUI submits the record for updation. But to my surprise the record is updated, which overwrites the last update.
I observsed that an extra select query is fired immediately before update and this select query fetches the latest version which was set by other process. Why Hibernate is making extra select call is something which I have no clue about.
Another observation, When I set Select-Before-Update="true" then only Hibernate complains.