Example usage for org.springframework.dao UncategorizedDataAccessException UncategorizedDataAccessException

List of usage examples for org.springframework.dao UncategorizedDataAccessException UncategorizedDataAccessException

Introduction

In this page you can find the example usage for org.springframework.dao UncategorizedDataAccessException UncategorizedDataAccessException.

Prototype

public UncategorizedDataAccessException(@Nullable String msg, @Nullable Throwable cause) 

Source Link

Document

Constructor for UncategorizedDataAccessException.

Usage

From source file:org.seasar.doma.boot.autoconfigure.DomaPersistenceExceptionTranslator.java

@Override
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
    if (!(ex instanceof JdbcException)) {
        // Fallback to other translators if not JdbcException
        return null;
    }//from   w w  w  .ja va  2s.  co  m

    if (ex instanceof OptimisticLockException) {
        return new OptimisticLockingFailureException(ex.getMessage(), ex);
    } else if (ex instanceof UniqueConstraintException) {
        return new DuplicateKeyException(ex.getMessage(), ex);
    } else if (ex instanceof NonUniqueResultException || ex instanceof NonSingleColumnException) {
        return new IncorrectResultSizeDataAccessException(ex.getMessage(), 1, ex);
    } else if (ex instanceof NoResultException) {
        return new EmptyResultDataAccessException(ex.getMessage(), 1, ex);
    } else if (ex instanceof UnknownColumnException || ex instanceof ResultMappingException) {
        return new TypeMismatchDataAccessException(ex.getMessage(), ex);
    }

    if (ex.getCause() instanceof SQLException) {
        SQLException e = (SQLException) ex.getCause();
        String sql = null;
        if (ex instanceof SqlExecutionException) {
            sql = ((SqlExecutionException) ex).getRawSql();
        }
        return translator.translate(ex.getMessage(), sql, e);
    }

    return new UncategorizedDataAccessException(ex.getMessage(), ex) {
    };
}