Polishing

This commit is contained in:
Juergen Hoeller 2018-07-09 15:53:44 +02:00
parent d9e8d3bbe1
commit a80c5121fe
4 changed files with 24 additions and 24 deletions

View File

@ -180,9 +180,9 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
}
// First, try custom translation from overridden method.
DataAccessException dex = customTranslate(task, sql, sqlEx);
if (dex != null) {
return dex;
DataAccessException dae = customTranslate(task, sql, sqlEx);
if (dae != null) {
return dae;
}
// Next, try the custom SQLException translator, if available.
@ -288,15 +288,15 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
}
/**
* Subclasses can override this method to attempt a custom mapping from SQLException
* to DataAccessException.
* Subclasses can override this method to attempt a custom mapping from
* {@link SQLException} to {@link DataAccessException}.
* @param task readable text describing the task being attempted
* @param sql the SQL query or update that caused the problem. May be {@code null}.
* @param sql the SQL query or update that caused the problem (may be {@code null})
* @param sqlEx the offending SQLException
* @return null if no custom translation was possible, otherwise a DataAccessException
* resulting from custom translation. This exception should include the sqlEx parameter
* as a nested root cause. This implementation always returns null, meaning that
* the translator always falls back to the default error codes.
* @return {@code null} if no custom translation applies, otherwise a {@link DataAccessException}
* resulting from custom translation. This exception should include the {@code sqlEx} parameter
* as a nested root cause. This implementation always returns {@code null}, meaning that the
* translator always falls back to the default error codes.
*/
@Nullable
protected DataAccessException customTranslate(String task, @Nullable String sql, SQLException sqlEx) {
@ -304,16 +304,16 @@ public class SQLErrorCodeSQLExceptionTranslator extends AbstractFallbackSQLExcep
}
/**
* Create a custom DataAccessException, based on a given exception
* class from a CustomSQLErrorCodesTranslation definition.
* Create a custom {@link DataAccessException}, based on a given exception
* class from a {@link CustomSQLErrorCodesTranslation} definition.
* @param task readable text describing the task being attempted
* @param sql the SQL query or update that caused the problem. May be {@code null}.
* @param sql the SQL query or update that caused the problem (may be {@code null})
* @param sqlEx the offending SQLException
* @param exceptionClass the exception class to use, as defined in the
* CustomSQLErrorCodesTranslation definition
* @return null if the custom exception could not be created, otherwise
* the resulting DataAccessException. This exception should include the
* sqlEx parameter as a nested root cause.
* {@link CustomSQLErrorCodesTranslation} definition
* @return {@code null} if the custom exception could not be created, otherwise
* the resulting {@link DataAccessException}. This exception should include the
* {@code sqlEx} parameter as a nested root cause.
* @see CustomSQLErrorCodesTranslation#setExceptionClass
*/
@Nullable

View File

@ -491,10 +491,10 @@ public abstract class ExtendedEntityManagerCreator {
}
private RuntimeException convertException(RuntimeException ex) {
DataAccessException daex = (this.exceptionTranslator != null) ?
DataAccessException dae = (this.exceptionTranslator != null) ?
this.exceptionTranslator.translateExceptionIfPossible(ex) :
EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(ex);
return (daex != null ? daex : ex);
return (dae != null ? dae : ex);
}
}

View File

@ -533,9 +533,9 @@ public class JpaTransactionManager extends AbstractPlatformTransactionManager
}
catch (RollbackException ex) {
if (ex.getCause() instanceof RuntimeException) {
DataAccessException dex = getJpaDialect().translateExceptionIfPossible((RuntimeException) ex.getCause());
if (dex != null) {
throw dex;
DataAccessException dae = getJpaDialect().translateExceptionIfPossible((RuntimeException) ex.getCause());
if (dae != null) {
throw dae;
}
}
throw new TransactionSystemException("Could not commit JPA transaction", ex);

View File

@ -239,8 +239,8 @@ public abstract class DataAccessUtils {
RuntimeException rawException, PersistenceExceptionTranslator pet) {
Assert.notNull(pet, "PersistenceExceptionTranslator must not be null");
DataAccessException dex = pet.translateExceptionIfPossible(rawException);
return (dex != null ? dex : rawException);
DataAccessException dae = pet.translateExceptionIfPossible(rawException);
return (dae != null ? dae : rawException);
}
}