CacheSQLStateConverterpublic class CacheSQLStateConverter extends Object implements SQLExceptionConverterA SQLExceptionConverter implementation specific to Caché SQL,
accounting for its custom integrity constraint violation error codes. |
Fields Summary |
---|
private ViolatedConstraintNameExtracter | extracter | private static final Set | SQL_GRAMMAR_CATEGORIES | private static final Set | DATA_CATEGORIES | private static final Set | INTEGRITY_VIOLATION_CATEGORIES | private static final Set | CONNECTION_CATEGORIES |
Constructors Summary |
---|
public CacheSQLStateConverter(ViolatedConstraintNameExtracter extracter)
SQL_GRAMMAR_CATEGORIES.add( "07" );
SQL_GRAMMAR_CATEGORIES.add( "37" );
SQL_GRAMMAR_CATEGORIES.add( "42" );
SQL_GRAMMAR_CATEGORIES.add( "65" );
SQL_GRAMMAR_CATEGORIES.add( "S0" );
SQL_GRAMMAR_CATEGORIES.add( "20" );
DATA_CATEGORIES.add( "22" );
DATA_CATEGORIES.add( "21" );
DATA_CATEGORIES.add( "02" );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 119 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 120 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 121 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 122 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 123 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 124 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 125 ) );
INTEGRITY_VIOLATION_CATEGORIES.add( new Integer( 127 ) );
CONNECTION_CATEGORIES.add( "08" );
this.extracter = extracter;
|
Methods Summary |
---|
public org.hibernate.JDBCException | convert(java.sql.SQLException sqlException, java.lang.String message, java.lang.String sql)Convert the given SQLException into Hibernate's JDBCException hierarchy.
String sqlStateClassCode = JDBCExceptionHelper.extractSqlStateClassCode( sqlException );
Integer errorCode = new Integer( JDBCExceptionHelper.extractErrorCode( sqlException ) );
if ( sqlStateClassCode != null ) {
if ( SQL_GRAMMAR_CATEGORIES.contains( sqlStateClassCode ) ) {
return new SQLGrammarException( message, sqlException, sql );
}
else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( errorCode ) ) {
String constraintName = extracter.extractConstraintName( sqlException );
return new ConstraintViolationException( message, sqlException, sql, constraintName );
}
else if ( CONNECTION_CATEGORIES.contains( sqlStateClassCode ) ) {
return new JDBCConnectionException( message, sqlException, sql );
}
else if ( DATA_CATEGORIES.contains( sqlStateClassCode ) ) {
return new DataException( message, sqlException, sql );
}
}
return handledNonSpecificException( sqlException, message, sql );
| protected org.hibernate.JDBCException | handledNonSpecificException(java.sql.SQLException sqlException, java.lang.String message, java.lang.String sql)Handle an exception not converted to a specific type based on the SQLState.
return new GenericJDBCException( message, sqlException, sql );
|
|