diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/KeyValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/KeyValue.java index 6069c2daec..de8b3548c7 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/KeyValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/KeyValue.java @@ -7,7 +7,6 @@ package org.hibernate.mapping; import org.hibernate.dialect.Dialect; -import org.hibernate.id.IdentifierGenerator; import org.hibernate.generator.Generator; /** @@ -30,16 +29,4 @@ public interface KeyValue extends Value { Generator createGenerator(Dialect dialect, RootClass rootClass); - /** - * @deprecated Use {@link #createGenerator(Dialect, RootClass)} instead. - * No longer used except in legacy tests. - * - * @return {@code null} if the {@code Generator} returned by {@link #createGenerator} is not an instance - * of {@link IdentifierGenerator}. - */ - @Deprecated(since="6.2", forRemoval = true) - default IdentifierGenerator createIdentifierGenerator(Dialect dialect, RootClass rootClass) { - final Generator generator = createGenerator( dialect, rootClass ); - return generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null; - } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/CustomNamingStrategyTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/CustomNamingStrategyTests.java index 3e77df76d9..feeebf3f74 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/CustomNamingStrategyTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/CustomNamingStrategyTests.java @@ -15,6 +15,9 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.dialect.Dialect; +import org.hibernate.generator.Generator; +import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.enhanced.ImplicitDatabaseObjectNamingStrategy; import org.hibernate.boot.model.relational.QualifiedName; import org.hibernate.boot.model.relational.QualifiedSequenceName; @@ -24,6 +27,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.id.PersistentIdentifierGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.internal.util.config.ConfigurationHelper; +import org.hibernate.mapping.KeyValue; import org.hibernate.service.ServiceRegistry; import org.hibernate.testing.orm.junit.DomainModel; @@ -52,10 +56,10 @@ public class CustomNamingStrategyTests { final JdbcServices jdbcServices = serviceRegistryScope.getRegistry().getService( JdbcServices.class ); final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); - final SequenceStyleGenerator generator = (SequenceStyleGenerator) entityDescriptor.getIdentifier().createIdentifierGenerator( - jdbcEnvironment.getDialect(), - entityDescriptor - ); + KeyValue keyValue = entityDescriptor.getIdentifier(); + Dialect dialect = jdbcEnvironment.getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, entityDescriptor); + final SequenceStyleGenerator generator = (SequenceStyleGenerator) (generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null); final String sequenceName = generator.getDatabaseStructure().getPhysicalName().getObjectName().getText(); assertThat( sequenceName ).isEqualTo( "ents_ids_seq" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/SequenceNamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/SequenceNamingStrategyTest.java index 3accb7510b..e8410cb97b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/SequenceNamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/SequenceNamingStrategyTest.java @@ -20,12 +20,14 @@ import org.hibernate.boot.model.relational.Sequence; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.generator.Generator; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.enhanced.LegacyNamingStrategy; import org.hibernate.id.enhanced.SingleNamingStrategy; import org.hibernate.id.enhanced.SequenceStructure; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.StandardNamingStrategy; +import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.service.ServiceRegistry; @@ -159,7 +161,9 @@ public class SequenceNamingStrategyTest { } private IdentifierGenerator extractGenerator(PersistentClass entityBinding) { - return entityBinding.getIdentifier().createIdentifierGenerator(null, null ); + KeyValue keyValue = entityBinding.getIdentifier(); + final Generator generator = keyValue.createGenerator(null, null); + return generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null; } @Entity(name = "TestEntity") diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/TableNamingStrategyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/TableNamingStrategyTest.java index e23fcd0d89..7e76dba264 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/TableNamingStrategyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/enhanced/TableNamingStrategyTest.java @@ -18,10 +18,12 @@ import org.hibernate.boot.model.relational.Namespace; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.generator.Generator; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.enhanced.LegacyNamingStrategy; import org.hibernate.id.enhanced.SingleNamingStrategy; import org.hibernate.id.enhanced.StandardNamingStrategy; +import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Table; import org.hibernate.service.ServiceRegistry; @@ -140,7 +142,9 @@ public class TableNamingStrategyTest { } private IdentifierGenerator extractGenerator(PersistentClass entityBinding) { - return entityBinding.getIdentifier().createIdentifierGenerator(null, null ); + KeyValue keyValue = entityBinding.getIdentifier(); + final Generator generator = keyValue.createGenerator(null, null); + return generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/uuid/GeneratedValueTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/uuid/GeneratedValueTest.java index 5028313e2b..ff74b6dbf3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/uuid/GeneratedValueTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/uuid/GeneratedValueTest.java @@ -20,9 +20,12 @@ import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.dialect.Dialect; import org.hibernate.dialect.SybaseDialect; +import org.hibernate.generator.Generator; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.UUIDGenerator; +import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.RootClass; @@ -55,10 +58,10 @@ public class GeneratedValueTest { PersistentClass entityBinding = metadata.getEntityBinding( TheEntity.class.getName() ); assertEquals( UUID.class, entityBinding.getIdentifier().getType().getReturnedClass() ); - IdentifierGenerator generator = entityBinding.getIdentifier().createIdentifierGenerator( - metadata.getDatabase().getDialect(), - (RootClass) entityBinding - ); + KeyValue keyValue = entityBinding.getIdentifier(); + Dialect dialect = metadata.getDatabase().getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityBinding); + IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; assertTyping( UUIDGenerator.class, generator ); // now a functional test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java index 8ee3fc4922..8b63f27fe4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/auto/AutoGenerationTypeTests.java @@ -20,7 +20,9 @@ import org.hibernate.annotations.CollectionIdJdbcTypeCode; import org.hibernate.boot.Metadata; import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; +import org.hibernate.generator.Generator; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IncrementGenerator; import org.hibernate.id.UUIDGenerator; @@ -59,10 +61,9 @@ public class AutoGenerationTypeTests { final PersistentClass entityBinding = metadata.getEntityBinding( Entity1.class.getName() ); final KeyValue idMapping = entityBinding.getRootClass().getIdentifier(); - final SequenceStyleGenerator entityIdGenerator = (SequenceStyleGenerator) idMapping.createIdentifierGenerator( - new H2Dialect(), - entityBinding.getRootClass() - ); + Dialect dialect = new H2Dialect(); + final Generator generator = idMapping.createGenerator( dialect, entityBinding.getRootClass()); + final SequenceStyleGenerator entityIdGenerator = (SequenceStyleGenerator) (generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null); final DatabaseStructure database1Structure = entityIdGenerator.getDatabaseStructure(); @@ -83,10 +84,9 @@ public class AutoGenerationTypeTests { final PersistentClass entityBinding = metadata.getEntityBinding( Entity2.class.getName() ); final KeyValue idMapping = entityBinding.getRootClass().getIdentifier(); - final SequenceStyleGenerator idGenerator = (SequenceStyleGenerator) idMapping.createIdentifierGenerator( - new H2Dialect(), - entityBinding.getRootClass() - ); + Dialect dialect = new H2Dialect(); + final Generator generator = idMapping.createGenerator( dialect, entityBinding.getRootClass()); + final SequenceStyleGenerator idGenerator = (SequenceStyleGenerator) (generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null); final DatabaseStructure database2Structure = idGenerator.getDatabaseStructure(); @@ -112,10 +112,9 @@ public class AutoGenerationTypeTests { final Property theTwos = entity1Binding.getProperty( "theTwos" ); final IdentifierBag idBagMapping = (IdentifierBag) theTwos.getValue(); final KeyValue collectionIdMapping = idBagMapping.getIdentifier(); - final SequenceStyleGenerator collectionIdGenerator = (SequenceStyleGenerator) collectionIdMapping.createIdentifierGenerator( - new H2Dialect(), - null - ); + Dialect dialect = new H2Dialect(); + final Generator generator = collectionIdMapping.createGenerator( dialect, null); + final SequenceStyleGenerator collectionIdGenerator = (SequenceStyleGenerator) (generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null); final DatabaseStructure idBagIdGeneratorDbStructure = collectionIdGenerator.getDatabaseStructure(); @@ -133,10 +132,9 @@ public class AutoGenerationTypeTests { final PersistentClass entityBinding = metadata.getEntityBinding( Entity4.class.getName() ); final KeyValue idMapping = entityBinding.getRootClass().getIdentifier(); - final IdentifierGenerator idGenerator = idMapping.createIdentifierGenerator( - new H2Dialect(), - entityBinding.getRootClass() - ); + Dialect dialect = new H2Dialect(); + final Generator generator = idMapping.createGenerator( dialect, entityBinding.getRootClass()); + final IdentifierGenerator idGenerator = generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null; assertThat( idGenerator, instanceOf( UUIDGenerator.class ) ); } @@ -151,10 +149,9 @@ public class AutoGenerationTypeTests { final PersistentClass entityBinding = metadata.getEntityBinding( Entity3.class.getName() ); final KeyValue idMapping = entityBinding.getRootClass().getIdentifier(); - final IdentifierGenerator idGenerator = idMapping.createIdentifierGenerator( - new H2Dialect(), - entityBinding.getRootClass() - ); + Dialect dialect = new H2Dialect(); + final Generator generator = idMapping.createGenerator( dialect, entityBinding.getRootClass()); + final IdentifierGenerator idGenerator = generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null; assertThat( idGenerator, instanceOf( IncrementGenerator.class ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/userdefined/UserDefinedGeneratorsTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/userdefined/UserDefinedGeneratorsTests.java index 3d9d40397a..7b6473ab42 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/userdefined/UserDefinedGeneratorsTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/userdefined/UserDefinedGeneratorsTests.java @@ -15,9 +15,12 @@ import org.hibernate.boot.MetadataSources; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.generator.Generator; import org.hibernate.id.IdentifierGenerator; +import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions; @@ -76,18 +79,16 @@ public class UserDefinedGeneratorsTests { final PersistentClass entityBinding1 = metadata.getEntityBinding( Entity1.class.getName() ); final PersistentClass entityBinding2 = metadata.getEntityBinding( Entity2.class.getName() ); - final IdentifierGenerator generator1 = entityBinding1.getRootClass() - .getIdentifier() - .createIdentifierGenerator( - new H2Dialect(), - entityBinding1.getRootClass() - ); - final IdentifierGenerator generator2 = entityBinding2.getRootClass() - .getIdentifier() - .createIdentifierGenerator( - new H2Dialect(), - entityBinding2.getRootClass() - ); + KeyValue keyValue1 = entityBinding1.getRootClass() + .getIdentifier(); + Dialect dialect1 = new H2Dialect(); + final Generator generator3 = keyValue1.createGenerator(dialect1, entityBinding1.getRootClass()); + final IdentifierGenerator generator1 = generator3 instanceof IdentifierGenerator ? (IdentifierGenerator) generator3 : null; + KeyValue keyValue = entityBinding2.getRootClass() + .getIdentifier(); + Dialect dialect = new H2Dialect(); + final Generator generator = keyValue.createGenerator( dialect, entityBinding2.getRootClass()); + final IdentifierGenerator generator2 = generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null; then( beanContainer ).should( times( 2 ) ).getBean( same( TestIdentifierGenerator.class ), any( LifecycleOptions.class ), diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/GeneratedValueTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/GeneratedValueTests.java index 21e1ee3b14..7b80e36ab9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/GeneratedValueTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/compliance/tck2_2/GeneratedValueTests.java @@ -15,12 +15,15 @@ import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.model.relational.internal.SqlStringGenerationContextImpl; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.spi.MetadataImplementor; +import org.hibernate.dialect.Dialect; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; +import org.hibernate.generator.Generator; import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IncrementGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.TableGenerator; +import org.hibernate.mapping.KeyValue; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.RootClass; @@ -56,10 +59,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ExplicitGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ExplicitGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); final SequenceStyleGenerator sequenceStyleGenerator = assertTyping( @@ -81,10 +84,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ImplicitSequenceGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ImplicitSequenceGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); final SequenceStyleGenerator sequenceStyleGenerator = assertTyping( @@ -109,10 +112,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ImplicitSequenceGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ImplicitSequenceGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); final SequenceStyleGenerator sequenceStyleGenerator = assertTyping( @@ -139,10 +142,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ExplicitSequenceGeneratorImplicitNameEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; Database database = bootModel.getDatabase(); SqlStringGenerationContext sqlStringGenerationContext = SqlStringGenerationContextImpl.forTests( database.getJdbcEnvironment() ); @@ -182,10 +185,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ImplicitTableGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ImplicitTableGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); final TableGenerator tableGenerator = assertTyping( TableGenerator.class, generator ); @@ -205,10 +208,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ExplicitTableGeneratorImplicitNameEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ExplicitTableGeneratorImplicitNameEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); final TableGenerator tableGenerator = assertTyping( TableGenerator.class, generator ); @@ -228,10 +231,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ExplicitTableGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ExplicitTableGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); final TableGenerator tableGenerator = assertTyping( TableGenerator.class, generator ); @@ -253,10 +256,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ExplicitIncrementGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ExplicitIncrementGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); assertTyping( IncrementGenerator.class, generator ); @@ -270,10 +273,10 @@ public class GeneratedValueTests extends BaseUnitTestCase { .addAnnotatedClass( ImplicitIncrementGeneratorEntity.class ) .buildMetadata(); final PersistentClass entityMapping = bootModel.getEntityBinding( ImplicitIncrementGeneratorEntity.class.getName() ); - final IdentifierGenerator generator = entityMapping.getIdentifier().createIdentifierGenerator( - ssr.getService( JdbcEnvironment.class ).getDialect(), - (RootClass) entityMapping - ); + KeyValue keyValue = entityMapping.getIdentifier(); + Dialect dialect = ssr.getService( JdbcEnvironment.class ).getDialect(); + final Generator generator1 = keyValue.createGenerator( dialect, (RootClass) entityMapping); + final IdentifierGenerator generator = generator1 instanceof IdentifierGenerator ? (IdentifierGenerator) generator1 : null; generator.initialize( SqlStringGenerationContextImpl.forTests( bootModel.getDatabase().getJdbcEnvironment() ) ); assertTyping( IncrementGenerator.class, generator );