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

下面列出了怎么用org.hibernate.exception.spi.SQLExceptionConverter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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;
                }
        };
}
 
源代码2 项目: 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);
        }
    };
}
 
源代码3 项目: 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;
                }
        };
}
 
源代码4 项目: lams   文件: AbstractCollectionPersister.java
protected SQLExceptionConverter getSQLExceptionConverter() {
	return getSQLExceptionHelper().getSqlExceptionConverter();
}
 
源代码5 项目: lams   文件: SessionFactoryDelegatingImpl.java
@Override
public SQLExceptionConverter getSQLExceptionConverter() {
	return delegate.getSQLExceptionConverter();
}
 
源代码6 项目: lemon   文件: SessionFactoryWrapper.java
public SQLExceptionConverter getSQLExceptionConverter() {
    return sessionFactoryImplementor.getSQLExceptionConverter();
}
 
源代码7 项目: keycloak   文件: DelegatingDialect.java
@Override
@Deprecated
public SQLExceptionConverter buildSQLExceptionConverter() {
    return getInstance().buildSQLExceptionConverter();
}
 
源代码8 项目: lams   文件: SqlExceptionHelper.java
/**
 * Create an exception helper with a specific exception converter.
 *
 * @param sqlExceptionConverter The exception converter to use.
 */
public SqlExceptionHelper(SQLExceptionConverter sqlExceptionConverter, boolean logWarnings) {
	this.sqlExceptionConverter = sqlExceptionConverter;
	this.logWarnings = logWarnings;
}
 
源代码9 项目: lams   文件: SqlExceptionHelper.java
/**
 * Access the current exception converter being used internally.
 *
 * @return The current exception converter.
 */
public SQLExceptionConverter getSqlExceptionConverter() {
	return sqlExceptionConverter;
}
 
源代码10 项目: 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 );
}
 
源代码11 项目: lams   文件: SessionFactoryImplementor.java
/**
 * Retrieves the SQLExceptionConverter in effect for this SessionFactory.
 *
 * @return The SQLExceptionConverter for this SessionFactory.
 *
 * @deprecated since 5.0; use {@link JdbcServices#getSqlExceptionHelper()} ->
 * {@link SqlExceptionHelper#getSqlExceptionConverter()} instead as obtained from {@link #getServiceRegistry()}
 */
@Deprecated
default SQLExceptionConverter getSQLExceptionConverter() {
	return getServiceRegistry().getService( JdbcServices.class ).getSqlExceptionHelper().getSqlExceptionConverter();
}
 
源代码12 项目: 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;
}
 
 类所在包
 同包方法