diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java index e4d7719015..ae857a579b 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaCreatorImpl.java @@ -463,7 +463,6 @@ public class SchemaCreatorImpl implements SchemaCreator { if ( importScriptSetting != null ) { final ScriptSourceInput importScriptInput = interpretScriptSourceSetting( importScriptSetting, classLoaderService, charsetName ); - log.executingImportScript( importScriptInput.toString() ); importScriptInput.prepare(); try { for ( String command : importScriptInput.read( commandExtractor ) ) { @@ -490,7 +489,6 @@ public class SchemaCreatorImpl implements SchemaCreator { final ScriptSourceInput importScriptInput = interpretLegacyImportScriptSetting( resourceName, classLoaderService, charsetName ); importScriptInput.prepare(); try { - log.executingImportScript( importScriptInput.toString() ); for ( String command : importScriptInput.read( commandExtractor ) ) { applySqlString( command, formatter, options, targets ); } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/AbstractScriptSourceInput.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/AbstractScriptSourceInput.java index e836b94071..18357e8b9a 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/AbstractScriptSourceInput.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/AbstractScriptSourceInput.java @@ -11,7 +11,10 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.hibernate.internal.CoreLogging; +import org.hibernate.internal.CoreMessageLogger; import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor; +import org.hibernate.tool.schema.internal.SchemaCreatorImpl; import org.hibernate.tool.schema.spi.ScriptSourceInput; /** @@ -20,13 +23,18 @@ import org.hibernate.tool.schema.spi.ScriptSourceInput; * @author Steve Ebersole */ public abstract class AbstractScriptSourceInput implements ScriptSourceInput { + + private static final CoreMessageLogger log = CoreLogging.messageLogger( SchemaCreatorImpl.class ); + protected abstract Reader reader(); @Override public void prepare() { - // by default there is nothing to do + log.executingImportScript( getScriptDescription() ); } + protected abstract String getScriptDescription(); + @Override public List read(ImportSqlCommandExtractor commandExtractor) { final String[] commands = commandExtractor.extractCommands( reader() ); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromFile.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromFile.java index 99dda8ebbd..61f5fb413d 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromFile.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromFile.java @@ -56,6 +56,11 @@ public class ScriptSourceInputFromFile extends AbstractScriptSourceInput impleme this.reader = toReader( file, charsetName ); } + @Override + protected String getScriptDescription() { + return file.getAbsolutePath(); + } + @SuppressWarnings("ResultOfMethodCallIgnored") private static Reader toReader(File file, String charsetName) { if ( ! file.exists() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromReader.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromReader.java index 6b0e396dc2..053f4e08f8 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromReader.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromReader.java @@ -32,6 +32,11 @@ public class ScriptSourceInputFromReader extends AbstractScriptSourceInput imple return reader; } + @Override + protected String getScriptDescription() { + return "[injected ScriptSourceInputFromReader script]"; + } + @Override public String toString() { return "ScriptSourceInputFromReader()"; diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromUrl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromUrl.java index 034ec8dad4..202f08bd13 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromUrl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/exec/ScriptSourceInputFromUrl.java @@ -65,6 +65,11 @@ public class ScriptSourceInputFromUrl extends AbstractScriptSourceInput implemen } } + @Override + protected String getScriptDescription() { + return url.toExternalForm(); + } + @Override public void release() { try { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java index b8fb0d368f..6276f86bfb 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ScriptSourceInput.java @@ -17,8 +17,9 @@ import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor; * @author Steve Ebersole */ public interface ScriptSourceInput { + /** - * Prepare source for use. + * Prepare source for use, and log that this script is about to be imported. */ void prepare();