Currently, the spring-orm class org.springframework.orm.jpa.vendor.HibernateJpaDialect translates Hibernate exceptions to Spring exceptions, but these exceptions can be wrapped in instances of org.hibernate.sql.exec.ExecutionException as I have noticed. As a result, such an exception is translated into a generic org.springframework.orm.jpa.JpaSystemException, which is a pity, as I would like to add retry behavior around a deadlock occurrence, but only then.

In concrete, a org.hibernate.exception.LockAcquisitionException is thrown by Hibernate, which is then wrapped into an org.hibernate.sql.exec.ExecutionException (on line 325 in org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl), which is then handled in an instance of org.springframework.orm.jpa.vendor.HibernateJpaDialect (method convertHibernateAccessException), and wrapped in a org.springframework.orm.jpa.JpaSystemException, since there is no translation for an ExecutionException.

I don't know if there are other cases where concrete translatable exceptions are 'lost' this way.

It would be nice if these wrapped exceptions could be unwrapped and translated, so we can act upon them correctly.

Comment From: bvklingeren

Thanks for the swift fix @jhoeller! Verified your changes and they work.