Properly return SQLExceptionTranslator-provided exception
Closes gh-31409
This commit is contained in:
parent
e9fcb21d55
commit
66ce8c9a25
|
@ -94,7 +94,7 @@ public class HibernateExceptionTranslator implements PersistenceExceptionTransla
|
||||||
DataAccessException dae = this.jdbcExceptionTranslator.translate(
|
DataAccessException dae = this.jdbcExceptionTranslator.translate(
|
||||||
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
|
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
|
||||||
if (dae != null) {
|
if (dae != null) {
|
||||||
throw dae;
|
return dae;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SessionFactoryUtils.convertHibernateAccessException(ex);
|
return SessionFactoryUtils.convertHibernateAccessException(ex);
|
||||||
|
|
|
@ -784,8 +784,6 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
|
||||||
/**
|
/**
|
||||||
* Convert the given HibernateException to an appropriate exception
|
* Convert the given HibernateException to an appropriate exception
|
||||||
* from the {@code org.springframework.dao} hierarchy.
|
* 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
|
* @param ex the HibernateException that occurred
|
||||||
* @return a corresponding DataAccessException
|
* @return a corresponding DataAccessException
|
||||||
* @see SessionFactoryUtils#convertHibernateAccessException
|
* @see SessionFactoryUtils#convertHibernateAccessException
|
||||||
|
|
|
@ -124,8 +124,8 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
* @see java.sql.SQLException
|
* @see java.sql.SQLException
|
||||||
* @see org.hibernate.JDBCException
|
* @see org.hibernate.JDBCException
|
||||||
|
* @see org.springframework.jdbc.support.SQLExceptionSubclassTranslator
|
||||||
* @see org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
|
* @see org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
|
||||||
* @see org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
|
|
||||||
*/
|
*/
|
||||||
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) {
|
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) {
|
||||||
this.jdbcExceptionTranslator = jdbcExceptionTranslator;
|
this.jdbcExceptionTranslator = jdbcExceptionTranslator;
|
||||||
|
@ -245,7 +245,7 @@ public class HibernateJpaDialect extends DefaultJpaDialect {
|
||||||
DataAccessException dae = this.jdbcExceptionTranslator.translate(
|
DataAccessException dae = this.jdbcExceptionTranslator.translate(
|
||||||
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
|
"Hibernate operation: " + jdbcEx.getMessage(), jdbcEx.getSQL(), jdbcEx.getSQLException());
|
||||||
if (dae != null) {
|
if (dae != null) {
|
||||||
throw dae;
|
return dae;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue