Skip to content

Commit 66ce8c9

Browse files
committed
Properly return SQLExceptionTranslator-provided exception
Closes gh-31409
1 parent e9fcb21 commit 66ce8c9

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected DataAccessException convertHibernateAccessException(HibernateException
9494
DataAccessException dae = this.jdbcExceptionTranslator.translate(
9595
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
9696
if (dae != null) {
97-
throw dae;
97+
return dae;
9898
}
9999
}
100100
return SessionFactoryUtils.convertHibernateAccessException(ex);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,6 @@ protected void disconnectOnCompletion(Session session) {
784784
/**
785785
* Convert the given HibernateException to an appropriate exception
786786
* from the {@code org.springframework.dao} hierarchy.
787-
* <p>Will automatically apply a specified SQLExceptionTranslator to a
788-
* Hibernate JDBCException, else rely on Hibernate's default translation.
789787
* @param ex the HibernateException that occurred
790788
* @return a corresponding DataAccessException
791789
* @see SessionFactoryUtils#convertHibernateAccessException

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaDialect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public void setPrepareConnection(boolean prepareConnection) {
124124
* @since 5.1
125125
* @see java.sql.SQLException
126126
* @see org.hibernate.JDBCException
127+
* @see org.springframework.jdbc.support.SQLExceptionSubclassTranslator
127128
* @see org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
128-
* @see org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
129129
*/
130130
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) {
131131
this.jdbcExceptionTranslator = jdbcExceptionTranslator;
@@ -245,7 +245,7 @@ protected DataAccessException convertHibernateAccessException(HibernateException
245245
DataAccessException dae = this.jdbcExceptionTranslator.translate(
246246
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
247247
if (dae != null) {
248-
throw dae;
248+
return dae;
249249
}
250250
}
251251

0 commit comments

Comments
 (0)