Skip to content

Commit 4b44553

Browse files
committed
HibernateExceptionTranslator avoids JPA IllegalState/ArgumentException translation
Issue: SPR-14681
1 parent 12afc26 commit 4b44553

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spring-orm-hibernate5/src/main/java/org/springframework/orm/hibernate5/HibernateExceptionTranslator.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
4848
if (ex instanceof HibernateException) {
4949
return convertHibernateAccessException((HibernateException) ex);
5050
}
51-
if (ex instanceof PersistenceException && ex.getCause() instanceof HibernateException) {
52-
return convertHibernateAccessException((HibernateException) ex.getCause());
51+
if (ex instanceof PersistenceException) {
52+
if (ex.getCause() instanceof HibernateException) {
53+
return convertHibernateAccessException((HibernateException) ex.getCause());
54+
}
55+
return EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex);
5356
}
54-
return EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex);
57+
return null;
5558
}
5659

5760
/**

0 commit comments

Comments
 (0)