I've noticed some cases where a native Hibernate exception is not wrapped in a
javax.persistence.OptimisticLockException.
EntityVerifyVersionProcess.java throws an org.hibernate.OptimisticLockException that is
passed on directly to JPA users.
EntityIncrementVersionProcess.java passes through the
org.hibernate.StaleObjectStateException from
AbstractEntityPersister#forceVersionIncrement() without wrapping. If wrapping in JPA
isn't possible, at least this one should be wrapped in an o.h.OptimisticLockException
for consistency sake.
Are JPA users expected to catch all three exceptions when using versioning? Is
OptimisticEntityLockException useful?