From 54bcf02831f938b0ca46d5a6a080ea5f03d4478e Mon Sep 17 00:00:00 2001 From: Gavin King Date: Wed, 23 Oct 2024 09:05:59 +0200 Subject: [PATCH] some cleanups and javadoc around SchemaManager Signed-off-by: Gavin King --- .../hibernate/relational/SchemaManager.java | 24 +++++---- .../internal/SchemaManagerImpl.java | 10 ++++ .../tool/schema/JdbcMetadaAccessStrategy.java | 8 +-- .../HibernateSchemaManagementTool.java | 50 ++++++++----------- .../tool/schema/spi/ExecutionOptions.java | 8 --- .../contributed/BasicContributorTests.java | 6 --- .../orm/test/schemaupdate/SchemaDropTest.java | 8 +-- .../SchemaUpdateTableBackedSequenceTest.java | 10 +--- .../CrossSchemaForeignKeyGenerationTest.java | 19 ++----- .../UniqueConstraintDropTest.java | 10 +--- .../DurationValidationTest.java | 10 +--- .../schemavalidation/EnumValidationTest.java | 9 +--- .../InstantValidationTest.java | 10 +--- .../LongVarcharValidationTest.java | 9 +--- .../NumericValidationTest.java | 9 +--- .../DefaultImportFileExecutionTest.java | 8 +-- .../tool/schema/ExecutionOptionsTestImpl.java | 8 +-- ...allySchemaValidatorImplConnectionTest.java | 12 ++--- .../IndividuallySchemaValidatorImplTest.java | 12 ++--- .../schema/MySQLColumnValidationTest.java | 12 ++--- ...ntsWithoutTerminalCharsImportFileTest.java | 10 +--- 21 files changed, 83 insertions(+), 179 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/relational/SchemaManager.java b/hibernate-core/src/main/java/org/hibernate/relational/SchemaManager.java index 4825c5f506f8..f028d618617a 100644 --- a/hibernate-core/src/main/java/org/hibernate/relational/SchemaManager.java +++ b/hibernate-core/src/main/java/org/hibernate/relational/SchemaManager.java @@ -15,6 +15,12 @@ * * @see org.hibernate.SessionFactory#getSchemaManager() * + * @apiNote This interface was added to JPA 3.2 as + * {@link jakarta.persistence.SchemaManager}, which it now inherits, + * with a minor change to the naming of its operations. It is retained + * for backward compatibility and as a place to define additional + * functionality in the future. + * * @since 6.2 * @author Gavin King */ @@ -27,6 +33,8 @@ public interface SchemaManager extends jakarta.persistence.SchemaManager { * * @param createSchemas if {@code true}, attempt to create schemas, * otherwise, assume the schemas already exist + * + * @apiNote This operation is a synonym for {@link #create}. */ void exportMappedObjects(boolean createSchemas); @@ -38,6 +46,8 @@ public interface SchemaManager extends jakarta.persistence.SchemaManager { * * @param dropSchemas if {@code true}, drop schemas, * otherwise, leave them be + * + * @apiNote This operation is a synonym for {@link #drop}. */ void dropMappedObjects(boolean dropSchemas); @@ -46,6 +56,8 @@ public interface SchemaManager extends jakarta.persistence.SchemaManager { * have the expected definitions. *

* Programmatic way to run {@link org.hibernate.tool.schema.spi.SchemaValidator}. + * + * @apiNote This operation is a synonym for {@link #validate}. */ void validateMappedObjects(); @@ -56,16 +68,8 @@ public interface SchemaManager extends jakarta.persistence.SchemaManager { * load script}. *

* Programmatic way to run {@link org.hibernate.tool.schema.spi.SchemaTruncator}. + * + * @apiNote This operation is a synonym for {@link #truncate}. */ void truncateMappedObjects(); - - @Override - default void create(boolean createSchemas) { - exportMappedObjects( createSchemas ); - } - - @Override - default void drop(boolean dropSchemas) { - dropMappedObjects( dropSchemas ); - } } diff --git a/hibernate-core/src/main/java/org/hibernate/relational/internal/SchemaManagerImpl.java b/hibernate-core/src/main/java/org/hibernate/relational/internal/SchemaManagerImpl.java index baa501551887..46f6f42630c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/relational/internal/SchemaManagerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/relational/internal/SchemaManagerImpl.java @@ -89,6 +89,16 @@ public void truncateMappedObjects() { ); } + @Override + public void create(boolean createSchemas) { + exportMappedObjects( createSchemas ); + } + + @Override + public void drop(boolean dropSchemas) { + dropMappedObjects( dropSchemas ); + } + @Override public void validate() throws SchemaValidationException { try { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java index 7e2d38cca080..ee6c81427b43 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java @@ -10,6 +10,8 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.internal.util.config.ConfigurationHelper; +import static org.hibernate.cfg.SchemaToolingSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY; + /** * Determines how JDBC metadata is read by the schema management tooling. * @@ -39,7 +41,7 @@ public String toString() { return super.toString().toLowerCase(Locale.ROOT); } - public static JdbcMetadaAccessStrategy interpretSetting(Map options) { + public static JdbcMetadaAccessStrategy interpretSetting(Map options) { if ( options == null ) { return interpretHbm2ddlSetting( null ); } @@ -48,7 +50,7 @@ else if ( ConfigurationHelper.getBoolean( AvailableSettings.ENABLE_SYNONYMS, opt return INDIVIDUALLY; } else { - return interpretHbm2ddlSetting( options.get( AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY ) ); + return interpretHbm2ddlSetting( options.get( HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY ) ); } } @@ -66,7 +68,7 @@ public static JdbcMetadaAccessStrategy interpretHbm2ddlSetting(Object value) { return strategy; } } - throw new IllegalArgumentException( "Unrecognized '" + AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY + "' value: '" + value + "'"); + throw new IllegalArgumentException( "Unrecognized '" + HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY + "' value: '" + value + "'"); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java index bb0cf8a0cfdb..e5626b104b04 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/internal/HibernateSchemaManagementTool.java @@ -9,7 +9,6 @@ import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.registry.selector.spi.StrategySelector; -import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo; @@ -18,7 +17,6 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.jdbc.spi.SqlExceptionHelper; import org.hibernate.engine.jdbc.spi.SqlStatementLogger; -import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.config.ConfigurationHelper; import org.hibernate.resource.transaction.spi.DdlTransactionIsolator; import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder; @@ -40,6 +38,7 @@ import org.hibernate.tool.schema.spi.ExtractionTool; import org.hibernate.tool.schema.spi.SchemaCreator; import org.hibernate.tool.schema.spi.SchemaDropper; +import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaFilterProvider; import org.hibernate.tool.schema.spi.SchemaManagementException; import org.hibernate.tool.schema.spi.SchemaManagementTool; @@ -61,8 +60,11 @@ import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DB_MINOR_VERSION; import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DB_NAME; import static org.hibernate.cfg.AvailableSettings.JAKARTA_HBM2DDL_DB_VERSION; +import static org.hibernate.cfg.SchemaToolingSettings.HBM2DDL_FILTER_PROVIDER; import static org.hibernate.internal.log.DeprecationLogger.DEPRECATION_LOGGER; import static org.hibernate.internal.util.NullnessHelper.coalesceSuppliedValues; +import static org.hibernate.internal.util.StringHelper.isEmpty; +import static org.hibernate.internal.util.StringHelper.isNotEmpty; /** * The standard Hibernate implementation of {@link SchemaManagementTool} @@ -101,33 +103,25 @@ public SchemaTruncator getSchemaTruncator(Map options) { @Override public SchemaMigrator getSchemaMigrator(Map options) { - if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) { - return new GroupedSchemaMigratorImpl( this, getSchemaFilterProvider( options ).getMigrateFilter() ); - } - else { - return new IndividuallySchemaMigratorImpl( this, getSchemaFilterProvider( options ).getMigrateFilter() ); - } + final SchemaFilter migrateFilter = getSchemaFilterProvider( options ).getMigrateFilter(); + return determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED + ? new GroupedSchemaMigratorImpl( this, migrateFilter ) + : new IndividuallySchemaMigratorImpl( this, migrateFilter ); } @Override public SchemaValidator getSchemaValidator(Map options) { - if ( determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED ) { - return new GroupedSchemaValidatorImpl( this, getSchemaFilterProvider( options ).getValidateFilter() ); - } - else { - return new IndividuallySchemaValidatorImpl( this, getSchemaFilterProvider( options ).getValidateFilter() ); - } + final SchemaFilter validateFilter = getSchemaFilterProvider( options ).getValidateFilter(); + return determineJdbcMetadaAccessStrategy( options ) == JdbcMetadaAccessStrategy.GROUPED + ? new GroupedSchemaValidatorImpl( this, validateFilter ) + : new IndividuallySchemaValidatorImpl( this, validateFilter ); } private SchemaFilterProvider getSchemaFilterProvider(Map options) { - final Object configuredOption = (options == null) - ? null - : options.get( AvailableSettings.HBM2DDL_FILTER_PROVIDER ); - return serviceRegistry.requireService( StrategySelector.class ).resolveDefaultableStrategy( - SchemaFilterProvider.class, - configuredOption, - DefaultSchemaFilterProvider.INSTANCE - ); + return serviceRegistry.requireService( StrategySelector.class ) + .resolveDefaultableStrategy( SchemaFilterProvider.class, + options == null ? null : options.get( HBM2DDL_FILTER_PROVIDER ), + DefaultSchemaFilterProvider.INSTANCE ); } private JdbcMetadaAccessStrategy determineJdbcMetadaAccessStrategy(Map options) { @@ -259,7 +253,7 @@ public JdbcContext resolveJdbcContext(Map configurationValues) { () -> configurationValues.get( JAKARTA_HBM2DDL_DB_NAME ), () -> { final String name = (String) configurationValues.get( DIALECT_DB_NAME ); - if ( StringHelper.isNotEmpty( name ) ) { + if ( isNotEmpty( name ) ) { DEPRECATION_LOGGER.deprecatedSetting( DIALECT_DB_NAME, JAKARTA_HBM2DDL_DB_NAME ); } return name; @@ -270,7 +264,7 @@ public JdbcContext resolveJdbcContext(Map configurationValues) { () -> configurationValues.get( JAKARTA_HBM2DDL_DB_VERSION ), () -> { final String name = (String) configurationValues.get( DIALECT_DB_VERSION ); - if ( StringHelper.isNotEmpty( name ) ) { + if ( isNotEmpty( name ) ) { DEPRECATION_LOGGER.deprecatedSetting( DIALECT_DB_VERSION, JAKARTA_HBM2DDL_DB_VERSION ); } return name; @@ -281,7 +275,7 @@ public JdbcContext resolveJdbcContext(Map configurationValues) { () -> configurationValues.get( JAKARTA_HBM2DDL_DB_MAJOR_VERSION ), () -> { final String name = (String) configurationValues.get( DIALECT_DB_MAJOR_VERSION ); - if ( StringHelper.isNotEmpty( name ) ) { + if ( isNotEmpty( name ) ) { DEPRECATION_LOGGER.deprecatedSetting( DIALECT_DB_MAJOR_VERSION, JAKARTA_HBM2DDL_DB_MAJOR_VERSION ); } return name; @@ -292,7 +286,7 @@ public JdbcContext resolveJdbcContext(Map configurationValues) { () -> configurationValues.get( JAKARTA_HBM2DDL_DB_MINOR_VERSION ), () -> { final String name = (String) configurationValues.get( DIALECT_DB_MINOR_VERSION ); - if ( StringHelper.isNotEmpty( name ) ) { + if ( isNotEmpty( name ) ) { DEPRECATION_LOGGER.deprecatedSetting( DIALECT_DB_MINOR_VERSION, JAKARTA_HBM2DDL_DB_MINOR_VERSION ); } return name; @@ -315,14 +309,14 @@ public String getDatabaseVersion() { @Override public int getDatabaseMajorVersion() { - return StringHelper.isEmpty( dbMajor ) + return isEmpty( dbMajor ) ? NO_VERSION : Integer.parseInt( dbMajor ); } @Override public int getDatabaseMinorVersion() { - return StringHelper.isEmpty( dbMinor ) + return isEmpty( dbMinor ) ? NO_VERSION : Integer.parseInt( dbMinor ); } 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 096aac6eae4e..0cacc25de754 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 @@ -20,12 +20,4 @@ public interface ExecutionOptions { boolean shouldManageNamespaces(); ExceptionHandler getExceptionHandler(); - - /** - * @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/test/java/org/hibernate/orm/test/mapping/contributed/BasicContributorTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/contributed/BasicContributorTests.java index fec2bc5d7fc5..007d7764bb43 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/contributed/BasicContributorTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/contributed/BasicContributorTests.java @@ -16,7 +16,6 @@ import org.hibernate.tool.schema.internal.SchemaDropperImpl; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.SourceDescriptor; @@ -71,11 +70,6 @@ public boolean shouldManageNamespaces() { public ExceptionHandler getExceptionHandler() { return Throwable::printStackTrace; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; final SchemaManagementTool schemaManagementTool = serviceRegistry.getService( SchemaManagementTool.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropTest.java index e092cf61441a..f7d1004c929c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaDropTest.java @@ -24,7 +24,6 @@ import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; import org.hibernate.tool.schema.spi.SchemaDropper; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.ScriptTargetOutput; @@ -101,7 +100,7 @@ public ScriptSourceInput getScriptSourceInput() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return serviceRegistry.getService( ConfigurationService.class ).getSettings(); } @@ -115,11 +114,6 @@ public ExceptionHandler getExceptionHandler() { return this; } - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } - @Override public void handleException(CommandAcceptanceException exception) { throw exception; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateTableBackedSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateTableBackedSequenceTest.java index 1b7f58308b67..6e925c48b5b3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateTableBackedSequenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/SchemaUpdateTableBackedSequenceTest.java @@ -27,7 +27,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptTargetOutput; import org.hibernate.tool.schema.spi.TargetDescriptor; @@ -92,19 +91,14 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }, ContributableMatcher.ALL, new TargetDescriptor() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java index c3a8c1935d83..dbc60d6fd791 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/foreignkeys/crossschema/CrossSchemaForeignKeyGenerationTest.java @@ -36,7 +36,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.ScriptTargetOutput; @@ -145,7 +144,7 @@ public void testSchemaMigrationForeignKeysAreGeneratedAfterAllTheTablesAreCreate final Database database = metadata.getDatabase(); final HibernateSchemaManagementTool tool = (HibernateSchemaManagementTool) ssr.getService( SchemaManagementTool.class ); - final Map configurationValues = ssr.getService( ConfigurationService.class ).getSettings(); + final Map configurationValues = ssr.requireService( ConfigurationService.class ).getSettings(); final ExecutionOptions options = new ExecutionOptions() { @Override public boolean shouldManageNamespaces() { @@ -153,7 +152,7 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } @@ -161,11 +160,6 @@ public Map getConfigurationValues() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; new IndividuallySchemaMigratorImpl( tool, DefaultSchemaFilter.INSTANCE ).doMigration( @@ -214,7 +208,7 @@ public void testImprovedSchemaMigrationForeignKeysAreGeneratedAfterAllTheTablesA final HibernateSchemaManagementTool tool = (HibernateSchemaManagementTool) ssr.getService( SchemaManagementTool.class ); - final Map configurationValues = ssr.getService( ConfigurationService.class ).getSettings(); + final Map configurationValues = ssr.requireService( ConfigurationService.class ).getSettings(); final ExecutionOptions options = new ExecutionOptions() { @Override public boolean shouldManageNamespaces() { @@ -222,7 +216,7 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } @@ -230,11 +224,6 @@ public Map getConfigurationValues() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; new GroupedSchemaMigratorImpl( tool, DefaultSchemaFilter.INSTANCE ).doMigration( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java index 11d771f1cce1..57c10ad42730 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemaupdate/uniqueconstraint/UniqueConstraintDropTest.java @@ -33,7 +33,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptTargetOutput; import org.hibernate.tool.schema.spi.TargetDescriptor; @@ -73,7 +72,7 @@ public void setUp() throws Exception { metadata.validate(); tool = (HibernateSchemaManagementTool) ssr.getService( SchemaManagementTool.class ); - final Map configurationValues = ssr.getService( ConfigurationService.class ).getSettings(); + final Map configurationValues = ssr.requireService( ConfigurationService.class ).getSettings(); options = new ExecutionOptions() { @Override public boolean shouldManageNamespaces() { @@ -81,7 +80,7 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } @@ -89,11 +88,6 @@ public Map getConfigurationValues() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/DurationValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/DurationValidationTest.java index 9e0a613ed608..0d8bb3db991c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/DurationValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/DurationValidationTest.java @@ -167,8 +167,8 @@ public static class TestEntity { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override @@ -180,10 +180,4 @@ public boolean shouldManageNamespaces() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } - } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/EnumValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/EnumValidationTest.java index 0b7fe83a7e38..d404f5bc2f6e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/EnumValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/EnumValidationTest.java @@ -177,8 +177,8 @@ public enum TestEnum { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override @@ -190,9 +190,4 @@ public boolean shouldManageNamespaces() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/InstantValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/InstantValidationTest.java index 295a2698c67d..e3627bc3c5bd 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/InstantValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/InstantValidationTest.java @@ -24,7 +24,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.ScriptTargetOutput; @@ -166,8 +165,8 @@ public static class TestEntity { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override @@ -179,9 +178,4 @@ public boolean shouldManageNamespaces() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/LongVarcharValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/LongVarcharValidationTest.java index ed3fe83da818..8d40f1f5fa0c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/LongVarcharValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/LongVarcharValidationTest.java @@ -174,8 +174,8 @@ public static class Translation { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override @@ -187,9 +187,4 @@ public boolean shouldManageNamespaces() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/NumericValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/NumericValidationTest.java index 84cce1c59a03..68d65235b5a3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/NumericValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/schemavalidation/NumericValidationTest.java @@ -150,8 +150,8 @@ public static class TestEntity { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override @@ -163,9 +163,4 @@ public boolean shouldManageNamespaces() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DefaultImportFileExecutionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DefaultImportFileExecutionTest.java index 5b94ea6ddd4a..cf98ba67a6f7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DefaultImportFileExecutionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/DefaultImportFileExecutionTest.java @@ -33,7 +33,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.ScriptTargetOutput; import org.hibernate.tool.schema.spi.SourceDescriptor; @@ -156,7 +155,7 @@ public ExecutionOptionsTestImpl(Map configValues) { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configValues; } @@ -170,11 +169,6 @@ public ExceptionHandler getExceptionHandler() { return this; } - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } - @Override public void handleException(CommandAcceptanceException exception) { throw exception; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/ExecutionOptionsTestImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/ExecutionOptionsTestImpl.java index 7739e38b9d65..d21d8cedb266 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/ExecutionOptionsTestImpl.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/ExecutionOptionsTestImpl.java @@ -10,7 +10,6 @@ import org.hibernate.tool.schema.spi.CommandAcceptanceException; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; /** * @author Steve Ebersole @@ -23,7 +22,7 @@ public class ExecutionOptionsTestImpl implements ExecutionOptions, ExceptionHand public static final ExecutionOptionsTestImpl INSTANCE = new ExecutionOptionsTestImpl(); @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return Collections.emptyMap(); } @@ -37,11 +36,6 @@ public ExceptionHandler getExceptionHandler() { return this; } - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } - @Override public void handleException(CommandAcceptanceException exception) { throw exception; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java index cb0569b17d21..b1fe62664c81 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplConnectionTest.java @@ -38,7 +38,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.SchemaValidator; @@ -74,7 +73,7 @@ public class IndividuallySchemaValidatorImplConnectionTest extends BaseUnitTestC protected HibernateSchemaManagementTool tool; - private Map configurationValues; + private Map configurationValues; private ExecutionOptions executionOptions; @@ -96,7 +95,7 @@ public void setUp() throws Exception { tool = (HibernateSchemaManagementTool) ssr.getService( SchemaManagementTool.class ); - configurationValues = ssr.getService( ConfigurationService.class ).getSettings(); + configurationValues = ssr.requireService( ConfigurationService.class ).getSettings(); executionOptions = new ExecutionOptions() { @Override @@ -105,7 +104,7 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } @@ -113,11 +112,6 @@ public Map getConfigurationValues() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java index 6f162fd9a6a3..17df865131fe 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/IndividuallySchemaValidatorImplTest.java @@ -35,7 +35,6 @@ import org.hibernate.tool.schema.spi.ContributableMatcher; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementException; import org.hibernate.tool.schema.spi.SchemaManagementTool; @@ -72,7 +71,7 @@ public class IndividuallySchemaValidatorImplTest extends BaseUnitTestCase { protected HibernateSchemaManagementTool tool; - private Map configurationValues; + private Map configurationValues; protected ExecutionOptions executionOptions; @@ -82,7 +81,7 @@ public void setUp() throws IOException { tool = (HibernateSchemaManagementTool) ssr.getService( SchemaManagementTool.class ); - configurationValues = ssr.getService( ConfigurationService.class ).getSettings(); + configurationValues = ssr.requireService( ConfigurationService.class ).getSettings(); executionOptions = new ExecutionOptions() { @Override @@ -91,7 +90,7 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationValues; } @@ -99,11 +98,6 @@ public Map getConfigurationValues() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/MySQLColumnValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/MySQLColumnValidationTest.java index 00821fc6ab0a..81693f83d738 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/MySQLColumnValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/MySQLColumnValidationTest.java @@ -23,7 +23,6 @@ import org.hibernate.tool.schema.internal.IndividuallySchemaValidatorImpl; import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.SchemaManagementException; import org.hibernate.tool.schema.spi.SchemaManagementTool; import org.hibernate.tool.schema.spi.SchemaValidator; @@ -138,8 +137,8 @@ public void testValidateColumn(SessionFactoryScope scope) { } ); - ConfigurationService configurationService = scope.getSessionFactory().getServiceRegistry().getService( - ConfigurationService.class ); + ConfigurationService configurationService = scope.getSessionFactory().getServiceRegistry() + .requireService( ConfigurationService.class ); ExecutionOptions executionOptions = new ExecutionOptions() { @Override public boolean shouldManageNamespaces() { @@ -147,7 +146,7 @@ public boolean shouldManageNamespaces() { } @Override - public Map getConfigurationValues() { + public Map getConfigurationValues() { return configurationService.getSettings(); } @@ -155,11 +154,6 @@ public Map getConfigurationValues() { public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } }; HibernateSchemaManagementTool hsmt = (HibernateSchemaManagementTool) scope.getSessionFactory() diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/StatementsWithoutTerminalCharsImportFileTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/StatementsWithoutTerminalCharsImportFileTest.java index 8e8522dabd33..ddbd77110264 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/StatementsWithoutTerminalCharsImportFileTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/tool/schema/scripts/StatementsWithoutTerminalCharsImportFileTest.java @@ -26,7 +26,6 @@ import org.hibernate.tool.schema.spi.ExceptionHandler; import org.hibernate.tool.schema.spi.ExecutionOptions; import org.hibernate.tool.schema.spi.SchemaCreator; -import org.hibernate.tool.schema.spi.SchemaFilter; import org.hibernate.tool.schema.spi.ScriptSourceInput; import org.hibernate.tool.schema.spi.ScriptTargetOutput; import org.hibernate.tool.schema.spi.SourceDescriptor; @@ -105,8 +104,8 @@ public void tearDown() { } @Override - public Map getConfigurationValues() { - return ssr.getService( ConfigurationService.class ).getSettings(); + public Map getConfigurationValues() { + return ssr.requireService( ConfigurationService.class ).getSettings(); } @Override @@ -119,11 +118,6 @@ public ExceptionHandler getExceptionHandler() { return ExceptionHandlerLoggedImpl.INSTANCE; } - @Override - public SchemaFilter getSchemaFilter() { - return SchemaFilter.ALL; - } - private static class SourceDescriptorImpl implements SourceDescriptor { /** * Singleton access