Java Code Examples for org.hibernate.dialect.Dialect.buildSQLExceptionConverter()

The following are Jave code examples for showing how to use buildSQLExceptionConverter() of the org.hibernate.dialect.Dialect class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: SQLExceptionConverterFactory.java   View Source Code Vote up 6 votes
/**
 * Build a SQLExceptionConverter instance.
 * <p/>
 * First, looks for a {@link 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.
 *
 * @param dialect    The defined dialect.
 * @param properties The configuration properties.
 * @return An appropriate SQLExceptionConverter instance.
 * @throws HibernateException There was an error building the SQLExceptionConverter.
 */
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.unableToConfigureSqlExceptionConverter( e );
			throw e;
		}
	}

	return converter;
}
 
Example 2
Project: lams   File: DatabaseMetadata.java   View Source Code Vote up 5 votes
public DatabaseMetadata(Connection connection, Dialect dialect, Configuration config, boolean extras)
		throws SQLException {
	sqlExceptionConverter = dialect.buildSQLExceptionConverter();
	meta = connection.getMetaData();
	this.extras = extras;
	initSequences( connection, dialect );
	if ( config != null
			&& ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, config.getProperties(), false ) ) {
		types = new String[] { "TABLE", "VIEW", "SYNONYM" };
	}
	else {
		types = new String[] { "TABLE", "VIEW" };
	}
}