| This is not a bug. In the testManagedEntity, the Session#update call makes no sense at all since the entity is already managed. More, the only time when setting the version property is taken into consideration is when you pass a detached entity via merge or update. Otherwise, the version you overwrite is skipped, which is actually a feature, not a bug. The only way to change an entity version is to either change the entity or via OPTIMISTIC_FORCE_INCREMENT or PESSIMISTIC_FORCE_INCREMENT. Therefore, I'm closing this issue since the described behavior is actually what we want. The automatic optimistic locking mechanism is meant to prevent lost updates at UPDATE/DELETE time, based on the loading-time version (the one taken from the hydrated state/loaded state), not the only taken from the entity version property. |