Skip to content

Commit f82dd46

Browse files
errandirvladmihalcea
authored andcommitted
HHH-11458 - Optimize the SQL formatter call when iterating through multiple targets
1 parent efc041c commit f82dd46

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,10 @@ private static void applySqlString(
519519
ExecutionOptions options,
520520
GenerationTarget... targets) {
521521
if ( !StringHelper.isEmpty( sqlString ) ) {
522+
String sqlStringFormatted = formatter.format( sqlString );
522523
for ( GenerationTarget target : targets ) {
523524
try {
524-
target.accept( formatter.format( sqlString ) );
525+
target.accept( sqlStringFormatted );
525526
}
526527
catch (CommandAcceptanceException e) {
527528
if ( !quiet ) {

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,9 @@ private static void applySqlString(
435435
}
436436

437437
try {
438+
String sqlStringFormatted = formatter.format( sqlString );
438439
for ( GenerationTarget target : targets ) {
439-
target.accept( formatter.format( sqlString ) );
440+
target.accept( sqlStringFormatted );
440441
}
441442
}
442443
catch (CommandAcceptanceException e) {

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,10 @@ private static void applySqlString(
369369
return;
370370
}
371371

372+
String sqlStringFormatted = formatter.format( sqlString );
372373
for ( GenerationTarget target : targets ) {
373374
try {
374-
target.accept( formatter.format( sqlString ) );
375+
target.accept( sqlStringFormatted );
375376
}
376377
catch (CommandAcceptanceException e) {
377378
options.getExceptionHandler().handleException( e );

0 commit comments

Comments
 (0)