hibernatejpaoptimistic-locking

Precisely when is the version field updated on a versioned JPA entity?


I would like to know precisely when the field annotated with @Version is effectively incremented (and accessible with its incremented value) on the entity among the following processings :

Thank you


Solution

  • You can find the code that is executed during update in org.hibernate.action.internal.EntityUpdateAction#execute. The version in the object is updated after @PreUpdate and before @PostUpdate are called.