public static SQLExceptionConverter buildMinimalSQLExceptionConverter() {
return new SQLExceptionConverter() {
public JDBCException convert(SQLException sqlException, String message, String sql) {
return new GenericJDBCException( message, sqlException, sql );
}
};
}
Builds a minimal converter. The instance returned here just always converts to
GenericJDBCException . |
public static SQLExceptionConverter buildSQLExceptionConverter(Dialect dialect,
Properties properties) throws HibernateException {
SQLExceptionConverter converter = null;
String converterClassName = ( String ) properties.get( Environment.SQL_EXCEPTION_CONVERTER );
if ( StringHelper.isNotEmpty( converterClassName ) ) {
converter = constructConverter( converterClassName, dialect.getViolatedConstraintNameExtracter() );
}
if ( converter == null ) {
log.trace( "Using dialect defined converter" );
converter = dialect.buildSQLExceptionConverter();
}
if ( converter instanceof Configurable ) {
try {
( ( Configurable ) converter ).configure( properties );
}
catch ( HibernateException e ) {
log.warn( "Unable to configure SQLExceptionConverter", e );
throw e;
}
}
return converter;
}
Build a SQLExceptionConverter instance.
First, looks for a Environment#SQL_EXCEPTION_CONVERTER property to see
if the configuration specified the class of a specific converter to use. If this
property is set, attempt to construct an instance of that class. If not set, or
if construction fails, the converter specific to the dialect will be used. |