diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java index f21945b8af..4b9b597633 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaMigrator.java @@ -244,7 +244,7 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator { sqlGenerationContext, targets ); tablesInformation.put( namespace, nameSpaceTablesInformation ); - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { for ( Sequence sequence : namespace.getSequences() ) { if ( contributableInclusionFilter.matches( sequence ) ) { checkExportIdentifier( sequence, exportIdentifiers); @@ -259,10 +259,10 @@ public abstract class AbstractSchemaMigrator implements SchemaMigrator { //NOTE : Foreign keys must be created *after* all tables of all namespaces for cross namespace fks. see HHH-10420 for ( Namespace namespace : database.getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { final NameSpaceTablesInformation nameSpaceTablesInformation = tablesInformation.get( namespace ); for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) && contributableInclusionFilter.matches( table ) ) { + if ( schemaFilter.includeTable( table ) && contributableInclusionFilter.matches( table ) ) { final TableInformation tableInformation = nameSpaceTablesInformation.getTableInformation( table ); if ( tableInformation == null || tableInformation.isPhysicalTable() ) { applyForeignKeys( table, tableInformation, dialect, metadata, formatter, options, diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java index b88967b163..18e95aa9d8 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/AbstractSchemaValidator.java @@ -93,15 +93,15 @@ public abstract class AbstractSchemaValidator implements SchemaValidator { ContributableMatcher contributableInclusionFilter, Dialect dialect) { for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { validateTables( metadata, databaseInformation, options, contributableInclusionFilter, dialect, namespace ); } } for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { for ( Sequence sequence : namespace.getSequences() ) { - if ( ! options.getSchemaFilter().includeSequence( sequence ) ) { + if ( !schemaFilter.includeSequence( sequence ) ) { continue; } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java index 9c4ff8131b..e5fe09cd98 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaMigratorImpl.java @@ -55,7 +55,7 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator { final NameSpaceTablesInformation tablesInformation = new NameSpaceTablesInformation( metadata.getDatabase().getJdbcEnvironment().getIdentifierHelper() ); - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { createSchemaAndCatalog( existingDatabase, options, @@ -71,7 +71,7 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator { final NameSpaceTablesInformation tables = existingDatabase.getTablesInformation( namespace ); for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() && contributableInclusionFilter.matches( table ) ) { checkExportIdentifier( table, exportIdentifiers ); @@ -88,7 +88,7 @@ public class GroupedSchemaMigratorImpl extends AbstractSchemaMigrator { } for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() && contributableInclusionFilter.matches( table ) ) { final TableInformation tableInformation = tablesInformation.getTableInformation( table ); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaValidatorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaValidatorImpl.java index 2716c1780e..9240ecf49e 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaValidatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/GroupedSchemaValidatorImpl.java @@ -40,7 +40,7 @@ public class GroupedSchemaValidatorImpl extends AbstractSchemaValidator { final NameSpaceTablesInformation tables = databaseInformation.getTablesInformation( namespace ); for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() && contributableInclusionFilter.matches( table ) ) { validateTable( diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java index 68e8611b10..cab1bf96a4 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaMigratorImpl.java @@ -55,7 +55,7 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator { final NameSpaceTablesInformation tablesInformation = new NameSpaceTablesInformation( metadata.getDatabase().getJdbcEnvironment().getIdentifierHelper() ); - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { createSchemaAndCatalog( existingDatabase, options, @@ -69,7 +69,7 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator { targets ); for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() && contributableInclusionFilter.matches( table ) ) { checkExportIdentifier( table, exportIdentifiers ); @@ -86,7 +86,7 @@ public class IndividuallySchemaMigratorImpl extends AbstractSchemaMigrator { } for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() && contributableInclusionFilter.matches( table ) ) { final TableInformation tableInformation = tablesInformation.getTableInformation( table ); diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaValidatorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaValidatorImpl.java index b7be9d2afb..0ef9209eed 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaValidatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/IndividuallySchemaValidatorImpl.java @@ -39,7 +39,7 @@ public class IndividuallySchemaValidatorImpl extends AbstractSchemaValidator { Dialect dialect, Namespace namespace) { for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && table.isPhysicalTable() && contributableInclusionFilter.matches( table ) ) { final TableInformation tableInformation = databaseInformation.getTableInformation( 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 01f1d7b9a7..730041d025 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 @@ -230,15 +230,16 @@ public class SchemaCreatorImpl implements SchemaCreator { final SqlStringGenerationContext context = createSqlStringGenerationContext(options, metadata); final Set exportIdentifiers = setOfSize(50); - createSchemasAndCatalogs(metadata, options, dialect, formatter, context, targets); + createSchemasAndCatalogs(metadata, options, schemaFilter, dialect, formatter, context, targets); // next, create all "before table" auxiliary objects createAuxiliaryObjectsBeforeTables(metadata, options, dialect, formatter, context, exportIdentifiers, targets); // next, create all UDTs - createUserDefinedTypes(metadata, options, dialect, formatter, context, targets); + createUserDefinedTypes(metadata, options, schemaFilter, dialect, formatter, context, targets); // then, create all schema objects (tables, sequences, constraints, etc) in each schema createSequencesTablesConstraints( metadata, options, + schemaFilter, contributableInclusionMatcher, dialect, formatter, @@ -247,7 +248,7 @@ public class SchemaCreatorImpl implements SchemaCreator { targets ); // foreign keys must be created after all tables of all namespaces for cross-namespace constraints (see HHH-10420) - createForeignKeys( metadata, options, contributableInclusionMatcher, dialect, formatter, context, targets ); + createForeignKeys( metadata, options, schemaFilter, contributableInclusionMatcher, dialect, formatter, context, targets ); // next, create all "after table" auxiliary objects createAuxiliaryObjectsAfterTables( metadata, options, dialect, formatter, context, exportIdentifiers, targets ); // and finally add all init commands @@ -287,6 +288,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createForeignKeys( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, @@ -294,9 +296,9 @@ public class SchemaCreatorImpl implements SchemaCreator { GenerationTarget[] targets) { for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { // foreign keys must be created after unique keys for numerous DBs (see HHH-8390) - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { for ( Table table : namespace.getTables() ) { - if ( options.getSchemaFilter().includeTable( table ) + if ( schemaFilter.includeTable( table ) && contributableInclusionMatcher.matches( table ) ) { // foreign keys for ( ForeignKey foreignKey : table.getForeignKeys().values() ) { @@ -316,6 +318,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createSequencesTablesConstraints( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, @@ -323,11 +326,12 @@ public class SchemaCreatorImpl implements SchemaCreator { Set exportIdentifiers, GenerationTarget[] targets) { for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { // sequences createSequences( metadata, options, + schemaFilter, contributableInclusionMatcher, dialect, formatter, @@ -340,6 +344,7 @@ public class SchemaCreatorImpl implements SchemaCreator { createTables( metadata, options, + schemaFilter, contributableInclusionMatcher, dialect, formatter, @@ -351,6 +356,7 @@ public class SchemaCreatorImpl implements SchemaCreator { createTableConstraints( metadata, options, + schemaFilter, contributableInclusionMatcher, dialect, formatter, @@ -366,6 +372,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createTableConstraints( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, @@ -375,7 +382,7 @@ public class SchemaCreatorImpl implements SchemaCreator { Namespace namespace) { for ( Table table : namespace.getTables() ) { if ( table.isPhysicalTable() - && options.getSchemaFilter().includeTable( table ) + && schemaFilter.includeTable( table ) && contributableInclusionMatcher.matches( table ) ) { // indexes for ( Index index : table.getIndexes().values() ) { @@ -404,6 +411,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createTables( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, @@ -414,7 +422,7 @@ public class SchemaCreatorImpl implements SchemaCreator { for ( Table table : namespace.getTables() ) { if ( table.isPhysicalTable() && !table.isView() - && options.getSchemaFilter().includeTable( table ) + && schemaFilter.includeTable( table ) && contributableInclusionMatcher.matches( table ) ) { checkExportIdentifier( table, exportIdentifiers ); applySqlStrings( @@ -428,7 +436,7 @@ public class SchemaCreatorImpl implements SchemaCreator { for ( Table table : namespace.getTables() ) { if ( table.isPhysicalTable() && table.isView() - && options.getSchemaFilter().includeTable( table ) + && schemaFilter.includeTable( table ) && contributableInclusionMatcher.matches( table ) ) { checkExportIdentifier( table, exportIdentifiers ); applySqlStrings( @@ -444,6 +452,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createSequences( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher contributableInclusionMatcher, Dialect dialect, Formatter formatter, @@ -452,7 +461,7 @@ public class SchemaCreatorImpl implements SchemaCreator { GenerationTarget[] targets, Namespace namespace) { for ( Sequence sequence : namespace.getSequences() ) { - if ( options.getSchemaFilter().includeSequence( sequence ) + if ( schemaFilter.includeSequence( sequence ) && contributableInclusionMatcher.matches( sequence ) ) { checkExportIdentifier( sequence, exportIdentifiers); applySqlStrings( @@ -491,12 +500,13 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createUserDefinedTypes( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets) { for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { for ( UserDefinedType userDefinedType : namespace.getDependencyOrderedUserDefinedTypes() ) { applySqlStrings( dialect.getUserDefinedTypeExporter() @@ -513,6 +523,7 @@ public class SchemaCreatorImpl implements SchemaCreator { private static void createSchemasAndCatalogs( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, @@ -523,7 +534,7 @@ public class SchemaCreatorImpl implements SchemaCreator { if ( tryToCreateCatalogs || tryToCreateSchemas ) { Set exportedCatalogs = new HashSet<>(); for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { Namespace.Name logicalName = namespace.getName(); Namespace.Name physicalName = namespace.getPhysicalName(); @@ -738,11 +749,6 @@ public class SchemaCreatorImpl implements SchemaCreator { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerHaltImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return schemaFilter; - } }; createFromMetadata( metadata, options, dialect, FormatStyle.NONE.getFormatter(), target ); @@ -798,11 +804,6 @@ public class SchemaCreatorImpl implements SchemaCreator { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return schemaFilter; - } }, (contributed) -> true, new SourceDescriptor() { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java index 76e6eeb814..d1b1ecdeca 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaDropperImpl.java @@ -222,8 +222,8 @@ public class SchemaDropperImpl implements SchemaDropper { targets ); dropAuxiliaryObjectsAfterTables( metadata, options, dialect, formatter, context, targets ); - dropUserDefinedTypes( metadata, options, dialect, formatter, context, targets ); - dropSchemasAndCatalogs( metadata, options, dialect, formatter, context, targets ); + dropUserDefinedTypes( metadata, options, schemaFilter, dialect, formatter, context, targets ); + dropSchemasAndCatalogs( metadata, options, schemaFilter, dialect, formatter, context, targets ); } private void dropConstraintsTablesSequences( @@ -236,7 +236,7 @@ public class SchemaDropperImpl implements SchemaDropper { GenerationTarget[] targets) { final Set exportIdentifiers = setOfSize( 50 ); for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { // we need to drop all constraints/indexes prior to dropping the tables applyConstraintDropping( @@ -253,6 +253,7 @@ public class SchemaDropperImpl implements SchemaDropper { dropTables( metadata, options, + schemaFilter, inclusionFilter, dialect, formatter, @@ -265,6 +266,7 @@ public class SchemaDropperImpl implements SchemaDropper { dropSequences( metadata, options, + schemaFilter, inclusionFilter, dialect, formatter, @@ -323,6 +325,7 @@ public class SchemaDropperImpl implements SchemaDropper { private static void dropSequences( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher inclusionFilter, Dialect dialect, Formatter formatter, @@ -331,7 +334,7 @@ public class SchemaDropperImpl implements SchemaDropper { Namespace namespace, GenerationTarget[] targets) { for ( Sequence sequence : namespace.getSequences() ) { - if ( options.getSchemaFilter().includeSequence( sequence ) + if ( schemaFilter.includeSequence( sequence ) && inclusionFilter.matches( sequence ) ) { checkExportIdentifier( sequence, exportIdentifiers); applySqlStrings( @@ -347,6 +350,7 @@ public class SchemaDropperImpl implements SchemaDropper { private static void dropTables( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher inclusionFilter, Dialect dialect, Formatter formatter, @@ -357,7 +361,7 @@ public class SchemaDropperImpl implements SchemaDropper { for ( Table table : namespace.getTables() ) { if ( table.isPhysicalTable() && table.isView() - && options.getSchemaFilter().includeTable( table ) + && schemaFilter.includeTable( table ) && inclusionFilter.matches( table ) ) { checkExportIdentifier( table, exportIdentifiers); applySqlStrings( @@ -371,7 +375,7 @@ public class SchemaDropperImpl implements SchemaDropper { for ( Table table : namespace.getTables() ) { if ( table.isPhysicalTable() && !table.isView() - && options.getSchemaFilter().includeTable( table ) + && schemaFilter.includeTable( table ) && inclusionFilter.matches( table ) ) { checkExportIdentifier( table, exportIdentifiers); applySqlStrings( @@ -387,12 +391,13 @@ public class SchemaDropperImpl implements SchemaDropper { private static void dropUserDefinedTypes( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, GenerationTarget[] targets) { for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { final List dependencyOrderedUserDefinedTypes = namespace.getDependencyOrderedUserDefinedTypes(); Collections.reverse( dependencyOrderedUserDefinedTypes ); for ( UserDefinedType userDefinedType : dependencyOrderedUserDefinedTypes ) { @@ -411,6 +416,7 @@ public class SchemaDropperImpl implements SchemaDropper { private static void dropSchemasAndCatalogs( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, Dialect dialect, Formatter formatter, SqlStringGenerationContext context, @@ -420,7 +426,7 @@ public class SchemaDropperImpl implements SchemaDropper { if ( tryToDropCatalogs || tryToDropSchemas) { final Set exportedCatalogs = new HashSet<>(); for ( Namespace namespace : metadata.getDatabase().getNamespaces() ) { - if ( options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( schemaFilter.includeNamespace( namespace ) ) { Namespace.Name logicalName = namespace.getName(); Namespace.Name physicalName = namespace.getPhysicalName(); @@ -464,7 +470,7 @@ public class SchemaDropperImpl implements SchemaDropper { if ( dialect.dropConstraints() ) { for ( Table table : namespace.getTables() ) { if ( table.isPhysicalTable() - && options.getSchemaFilter().includeTable( table ) + && schemaFilter.includeTable( table ) && inclusionFilter.matches( table ) ) { for ( ForeignKey foreignKey : table.getForeignKeys().values() ) { applySqlStrings( @@ -552,11 +558,6 @@ public class SchemaDropperImpl implements SchemaDropper { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return schemaFilter; - } }, (contributed) -> true, serviceRegistry.getService( JdbcEnvironment.class ).getDialect(), diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaTruncatorImpl.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaTruncatorImpl.java index d41e2345bb..5a2bfc9da3 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaTruncatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/SchemaTruncatorImpl.java @@ -58,9 +58,11 @@ public class SchemaTruncatorImpl implements SchemaTruncator { private static final Logger log = Logger.getLogger( SchemaTruncatorImpl.class ); private final HibernateSchemaManagementTool tool; + private final SchemaFilter schemaFilter; public SchemaTruncatorImpl(HibernateSchemaManagementTool tool, SchemaFilter truncatorFilter) { this.tool = tool; + schemaFilter = truncatorFilter; } @Override @@ -111,12 +113,13 @@ public class SchemaTruncatorImpl implements SchemaTruncator { final boolean format = Helper.interpretFormattingEnabled( options.getConfigurationValues() ); final Formatter formatter = format ? FormatStyle.DDL.getFormatter() : FormatStyle.NONE.getFormatter(); - truncateFromMetadata( metadata, options, contributableInclusionFilter, dialect, formatter, targets ); + truncateFromMetadata( metadata, options, schemaFilter, contributableInclusionFilter, dialect, formatter, targets ); } private void truncateFromMetadata( Metadata metadata, ExecutionOptions options, + SchemaFilter schemaFilter, ContributableMatcher contributableInclusionFilter, Dialect dialect, Formatter formatter, @@ -128,11 +131,11 @@ public class SchemaTruncatorImpl implements SchemaTruncator { for ( Namespace namespace : database.getNamespaces() ) { - if ( ! options.getSchemaFilter().includeNamespace( namespace ) ) { + if ( ! schemaFilter.includeNamespace( namespace ) ) { continue; } - disableConstraints( namespace, metadata, formatter, options, context, + disableConstraints( namespace, metadata, formatter, options, schemaFilter, context, contributableInclusionFilter, targets ); applySqlString( dialect.getTableCleaner().getSqlBeforeString(), formatter, options,targets ); @@ -142,7 +145,7 @@ public class SchemaTruncatorImpl implements SchemaTruncator { if ( ! table.isPhysicalTable() ) { continue; } - if ( ! options.getSchemaFilter().includeTable( table ) ) { + if ( ! schemaFilter.includeTable( table ) ) { continue; } if ( ! contributableInclusionFilter.matches( table ) ) { @@ -172,7 +175,7 @@ public class SchemaTruncatorImpl implements SchemaTruncator { // } applySqlString( dialect.getTableCleaner().getSqlAfterString(), formatter, options,targets ); - enableConstraints( namespace, metadata, formatter, options, context, + enableConstraints( namespace, metadata, formatter, options, schemaFilter, context, contributableInclusionFilter, targets ); } @@ -186,6 +189,7 @@ public class SchemaTruncatorImpl implements SchemaTruncator { Metadata metadata, Formatter formatter, ExecutionOptions options, + SchemaFilter schemaFilter, SqlStringGenerationContext context, ContributableMatcher contributableInclusionFilter, GenerationTarget... targets) { @@ -195,7 +199,7 @@ public class SchemaTruncatorImpl implements SchemaTruncator { if ( !table.isPhysicalTable() ) { continue; } - if ( ! options.getSchemaFilter().includeTable( table ) ) { + if ( ! schemaFilter.includeTable( table ) ) { continue; } if ( ! contributableInclusionFilter.matches( table ) ) { @@ -232,6 +236,7 @@ public class SchemaTruncatorImpl implements SchemaTruncator { Metadata metadata, Formatter formatter, ExecutionOptions options, + SchemaFilter schemaFilter, SqlStringGenerationContext context, ContributableMatcher contributableInclusionFilter, GenerationTarget... targets) { @@ -241,7 +246,7 @@ public class SchemaTruncatorImpl implements SchemaTruncator { if ( !table.isPhysicalTable() ) { continue; } - if ( ! options.getSchemaFilter().includeTable( table ) ) { + if ( ! schemaFilter.includeTable( table ) ) { continue; } if ( ! contributableInclusionFilter.matches( table ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java index c96f7bafb2..74a2b00b86 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/ExecutionOptions.java @@ -24,5 +24,11 @@ public interface ExecutionOptions { ExceptionHandler getExceptionHandler(); - SchemaFilter getSchemaFilter(); + /** + * @deprecated No longer used, see {@link org.hibernate.cfg.SchemaToolingSettings#HBM2DDL_FILTER_PROVIDER} + */ + @Deprecated( forRemoval = true ) + default SchemaFilter getSchemaFilter() { + throw new UnsupportedOperationException(); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java index 4d67d64b98..fc2d3ee444 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/spi/SchemaManagementToolCoordinator.java @@ -23,7 +23,6 @@ import org.hibernate.service.ServiceRegistry; import org.hibernate.tool.schema.Action; import org.hibernate.tool.schema.SourceType; import org.hibernate.tool.schema.TargetType; -import org.hibernate.tool.schema.internal.DefaultSchemaFilter; import org.hibernate.tool.schema.internal.ExceptionHandlerHaltImpl; import org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl; import org.hibernate.tool.schema.internal.Helper; @@ -173,17 +172,6 @@ public class SchemaManagementToolCoordinator { public static ExecutionOptions buildExecutionOptions( final Map configurationValues, final ExceptionHandler exceptionHandler) { - return buildExecutionOptions( - configurationValues, - DefaultSchemaFilter.INSTANCE, - exceptionHandler - ); - } - - public static ExecutionOptions buildExecutionOptions( - final Map configurationValues, - final SchemaFilter schemaFilter, - final ExceptionHandler exceptionHandler) { return new ExecutionOptions() { @Override public boolean shouldManageNamespaces() { @@ -199,14 +187,20 @@ public class SchemaManagementToolCoordinator { public ExceptionHandler getExceptionHandler() { return exceptionHandler; } - - @Override - public SchemaFilter getSchemaFilter() { - return schemaFilter; - } }; } + /** + * @deprecated Use {@link #buildExecutionOptions(Map, ExceptionHandler)} instead. + */ + @Deprecated(forRemoval = true) + public static ExecutionOptions buildExecutionOptions( + final Map configurationValues, + final SchemaFilter schemaFilter, + final ExceptionHandler exceptionHandler) { + return buildExecutionOptions( configurationValues, exceptionHandler ); + } + private static void performDatabaseAction( final Action action, Metadata metadata,