Skip to content

Commit

Permalink
Properly return SQLExceptionTranslator-provided exception
Browse files Browse the repository at this point in the history
Closes gh-31409
  • Loading branch information
jhoeller committed Oct 11, 2023
1 parent e9fcb21 commit 66ce8c9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected DataAccessException convertHibernateAccessException(HibernateException
DataAccessException dae = this.jdbcExceptionTranslator.translate(
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
if (dae != null) {
throw dae;
return dae;
}
}
return SessionFactoryUtils.convertHibernateAccessException(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,6 @@ protected void disconnectOnCompletion(Session session) {
/**
* Convert the given HibernateException to an appropriate exception
* from the {@code org.springframework.dao} hierarchy.
* <p>Will automatically apply a specified SQLExceptionTranslator to a
* Hibernate JDBCException, else rely on Hibernate's default translation.
* @param ex the HibernateException that occurred
* @return a corresponding DataAccessException
* @see SessionFactoryUtils#convertHibernateAccessException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void setPrepareConnection(boolean prepareConnection) {
* @since 5.1
* @see java.sql.SQLException
* @see org.hibernate.JDBCException
* @see org.springframework.jdbc.support.SQLExceptionSubclassTranslator
* @see org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
* @see org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
*/
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) {
this.jdbcExceptionTranslator = jdbcExceptionTranslator;
Expand Down Expand Up @@ -245,7 +245,7 @@ protected DataAccessException convertHibernateAccessException(HibernateException
DataAccessException dae = this.jdbcExceptionTranslator.translate(
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
if (dae != null) {
throw dae;
return dae;
}
}

Expand Down

0 comments on commit 66ce8c9

Please sign in to comment.