In my analysis of Hibernate 3.5.2 (now a bit old), I found that they sometimes throw an OptimisticLockException , and sometimes a StaleObjectStateException . Batch operations even throw a StaleStateException , which is a superclass of StaleObjectStateException , but does not have an entity instance.
It seems to me that this is incomplete refactoring, you probably need to catch both and react the same way.
source share