Java Code Examples for org.hibernate.engine.jdbc.internal.Formatter#format()

The following examples show how to use org.hibernate.engine.jdbc.internal.Formatter#format() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaCreatorImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void applySqlString(
		String sqlString,
		Formatter formatter,
		ExecutionOptions options,
		GenerationTarget... targets) {
	if ( StringHelper.isEmpty( sqlString ) ) {
		return;
	}

	try {
		String sqlStringFormatted = formatter.format( sqlString );
		for ( GenerationTarget target : targets ) {
			target.accept( sqlStringFormatted );
		}
	}
	catch (CommandAcceptanceException e) {
		options.getExceptionHandler().handleException( e );
	}
}
 
Example 2
Source File: AbstractSchemaMigrator.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void applySqlString(
		boolean quiet,
		String sqlString,
		Formatter formatter,
		ExecutionOptions options,
		GenerationTarget... targets) {
	if ( !StringHelper.isEmpty( sqlString ) ) {
		String sqlStringFormatted = formatter.format( sqlString );
		for ( GenerationTarget target : targets ) {
			try {
				target.accept( sqlStringFormatted );
			}
			catch (CommandAcceptanceException e) {
				if ( !quiet ) {
					options.getExceptionHandler().handleException( e );
				}
				// otherwise ignore the exception
			}
		}
	}
}
 
Example 3
Source File: SchemaDropperImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
private static void applySqlString(
		String sqlString,
		Formatter formatter,
		ExecutionOptions options,
		GenerationTarget... targets) {
	if ( StringHelper.isEmpty( sqlString ) ) {
		return;
	}

	String sqlStringFormatted = formatter.format( sqlString );
	for ( GenerationTarget target : targets ) {
		try {
			target.accept( sqlStringFormatted );
		}
		catch (CommandAcceptanceException e) {
			options.getExceptionHandler().handleException( e );
		}
	}
}
 
Example 4
Source File: SqlStatementLogger.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Log a SQL statement string using the specified formatter
 *
 * @param statement The SQL statement.
 * @param formatter The formatter to use.
 */
@AllowSysOut
public void logStatement(String statement, Formatter formatter) {
	if ( format ) {
		if ( logToStdout || LOG.isDebugEnabled() ) {
			statement = formatter.format( statement );
		}
	}
	LOG.debug( statement );
	if ( logToStdout ) {
		System.out.println( "Hibernate: " + statement );
	}
}