Java 类org.hibernate.exception.spi.SQLExceptionConverter 实例源码

项目:gemfirexd-oss    文件:GemFireXDDialect.java   
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
        return new SQLExceptionConverter() {
                @Override
                public JDBCException convert(SQLException sqlException,
                                String message, String sql) {
                        final String sqlState = JdbcExceptionHelper
                                        .extractSqlState(sqlException);
                        if (sqlState != null) {
                                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                                        return new SQLGrammarException(message, sqlException,
                                                        sql);
                                } else if (DATA_CATEGORIES.contains(sqlState)) {
                                        return new DataException(message, sqlException, sql);
                                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                                        return new LockAcquisitionException(message,
                                                        sqlException, sql);
                                }
                        }
                        return null;
                }
        };
}
项目:gemfirexd-oss    文件:GemFireXDDialect.java   
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
        return new SQLExceptionConverter() {
                @Override
                public JDBCException convert(SQLException sqlException,
                                String message, String sql) {
                        final String sqlState = JdbcExceptionHelper
                                        .extractSqlState(sqlException);
                        if (sqlState != null) {
                                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                                        return new SQLGrammarException(message, sqlException,
                                                        sql);
                                } else if (DATA_CATEGORIES.contains(sqlState)) {
                                        return new DataException(message, sqlException, sql);
                                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                                        return new LockAcquisitionException(message,
                                                        sqlException, sql);
                                }
                        }
                        return null;
                }
        };
}
项目:yeti    文件:SQLiteDialect.java   
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
    return new SQLExceptionConverter() {
        @Override
        public JDBCException convert(SQLException sqlException, String message, String sql) {
            final int errorCode = sqlException.getErrorCode();
            if (errorCode == SQLITE_CONSTRAINT) {
                final String constraintName = EXTRACTER.extractConstraintName(sqlException);
                return new ConstraintViolationException(message, sqlException, sql, constraintName);
            } else if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) {
                return new DataException(message, sqlException, sql);
            } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
                return new LockAcquisitionException(message, sqlException, sql);
            } else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL) || errorCode == SQLITE_NOTADB) {
                return new JDBCConnectionException(message, sqlException, sql);
            }
            return new GenericJDBCException(message, sqlException, sql);
        }
    };
}
项目:lemon    文件:SessionFactoryWrapper.java   
public SQLExceptionConverter getSQLExceptionConverter() {
    return sessionFactoryImplementor.getSQLExceptionConverter();
}
项目:lams    文件:AbstractCollectionPersister.java   
protected SQLExceptionConverter getSQLExceptionConverter() {
    return getSQLExceptionHelper().getSqlExceptionConverter();
}
项目:lams    文件:SessionFactoryImpl.java   
public SQLExceptionConverter getSQLExceptionConverter() {
    return getSQLExceptionHelper().getSqlExceptionConverter();
}
项目:hibernate-dynamic-dialects    文件:SessionFactoryImpl.java   
public SQLExceptionConverter getSQLExceptionConverter() {
    return getSQLExceptionHelper().getSqlExceptionConverter();
}
项目:org.fastnate    文件:AllowMissingIdentitySupportDialect.java   
@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
    return this.wrapped.buildSQLExceptionConverter();
}
项目:lams    文件:SqlExceptionHelper.java   
/**
 * Create an exception helper with a specific exception converter.
 *
 * @param sqlExceptionConverter The exception converter to use.
 */
public SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter) {
    this.sqlExceptionConverter = sqlExceptionConverter;
}
项目:lams    文件:SqlExceptionHelper.java   
/**
 * Access the current exception converter being used internally.
 *
 * @return The current exception converter.
 */
public SQLExceptionConverter getSqlExceptionConverter() {
    return sqlExceptionConverter;
}
项目:lams    文件:SqlExceptionHelper.java   
/**
 * Inject the exception converter to use.
 * <p/>
 * NOTE : <tt>null</tt> is allowed and signifies to use the default.
 *
 * @param sqlExceptionConverter The converter to use.
 */
public void setSqlExceptionConverter(SQLExceptionConverter sqlExceptionConverter) {
    this.sqlExceptionConverter = (sqlExceptionConverter == null ? DEFAULT_CONVERTER : sqlExceptionConverter);
}
项目:lams    文件:SessionFactoryImplementor.java   
/**
 * Retrieves the SQLExceptionConverter in effect for this SessionFactory.
 *
 * @return The SQLExceptionConverter for this SessionFactory.
 *
 */
public SQLExceptionConverter getSQLExceptionConverter();
项目:lams    文件:Dialect.java   
/**
 * Build an instance of the SQLExceptionConverter preferred by this dialect for
 * converting SQLExceptions into Hibernate's JDBCException hierarchy.
 * <p/>
 * The preferred method is to not override this method; if possible,
 * {@link #buildSQLExceptionConversionDelegate()} should be overridden
 * instead.
 *
 * If this method is not overridden, the default SQLExceptionConverter
 * implementation executes 3 SQLException converter delegates:
 * <ol>
 *     <li>a "static" delegate based on the JDBC 4 defined SQLException hierarchy;</li>
 *     <li>the vendor-specific delegate returned by {@link #buildSQLExceptionConversionDelegate()};
 *         (it is strongly recommended that specific Dialect implementations
 *         override {@link #buildSQLExceptionConversionDelegate()})</li>
 *     <li>a delegate that interprets SQLState codes for either X/Open or SQL-2003 codes,
 *         depending on java.sql.DatabaseMetaData#getSQLStateType</li>
 * </ol>
 * <p/>
 * If this method is overridden, it is strongly recommended that the
 * returned {@link SQLExceptionConverter} interpret SQL errors based on
 * vendor-specific error codes rather than the SQLState since the
 * interpretation is more accurate when using vendor-specific ErrorCodes.
 *
 * @return The Dialect's preferred SQLExceptionConverter, or null to
 * indicate that the default {@link SQLExceptionConverter} should be used.
 *
 * @see {@link #buildSQLExceptionConversionDelegate()}
 * @deprecated {@link #buildSQLExceptionConversionDelegate()} should be
 * overridden instead.
 */
@Deprecated
public SQLExceptionConverter buildSQLExceptionConverter() {
    return null;
}