fix logging of DDL
the DDL formatter was being applied twice
This commit is contained in:
parent
ff9a60601c
commit
493818141e
|
@ -45,7 +45,7 @@ public class DDLFormatterImpl implements Formatter {
|
|||
return formatAlterTable( sql );
|
||||
}
|
||||
else if ( lowerCaseSql.startsWith( "create" ) ) {
|
||||
return sql;
|
||||
return INITIAL_LINE + sql;
|
||||
}
|
||||
else if ( lowerCaseSql.startsWith( "alter table" ) ) {
|
||||
return formatAlterTable( sql );
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.sql.SQLException;
|
|||
import java.sql.SQLWarning;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.hibernate.engine.jdbc.internal.DDLFormatterImpl;
|
||||
import org.hibernate.engine.jdbc.internal.FormatStyle;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
|
@ -65,7 +65,7 @@ public class GenerationTargetToDatabase implements GenerationTarget {
|
|||
|
||||
@Override
|
||||
public void accept(String command) {
|
||||
getSqlStatementLogger().logStatement( command, DDLFormatterImpl.INSTANCE );
|
||||
getSqlStatementLogger().logStatement( command, FormatStyle.NONE.getFormatter() );
|
||||
|
||||
try {
|
||||
final Statement jdbcStatement = jdbcStatement();
|
||||
|
@ -83,12 +83,21 @@ public class GenerationTargetToDatabase implements GenerationTarget {
|
|||
}
|
||||
catch (SQLException e) {
|
||||
throw new CommandAcceptanceException(
|
||||
"Error executing DDL \"" + command + "\" via JDBC [" + e.getMessage() + "]",
|
||||
"Error executing DDL \"" + command + "\" via JDBC [" + stripSql(e) + "]",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip repetition of the SQL statement from h2 messages.
|
||||
*/
|
||||
private static String stripSql(SQLException e) {
|
||||
final String message = e.getMessage();
|
||||
int index = message.indexOf( " SQL statement:" );
|
||||
return index > 0 ? message.substring( 0, index ) : message;
|
||||
}
|
||||
|
||||
private Statement jdbcStatement() {
|
||||
if ( jdbcStatement == null ) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue