From 3e215b5ceeadcee94777485efd30496282d5034a Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 16 Sep 2024 16:08:13 -0500 Subject: [PATCH] HHH-18337 - SequenceStyleGenerator not respecting physical naming strategy --- .../hibernate/id/enhanced/SequenceStyleGenerator.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java index dc5bcb6ab42f..329ccb17713c 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/SequenceStyleGenerator.java @@ -206,10 +206,6 @@ public void create(GeneratorCreationContext creationContext) throws MappingExcep @Override public void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException { - if ( physicalNamingStrategy == null ) { - throw new IllegalStateException( "Expecting prior call to #create" ); - } - final JdbcEnvironment jdbcEnvironment = serviceRegistry.requireService( JdbcEnvironment.class ); final Dialect dialect = jdbcEnvironment.getDialect(); @@ -279,9 +275,9 @@ private int adjustIncrementSize( if ( sequenceMismatchStrategy != SequenceMismatchStrategy.NONE && optimizationStrategy.isPooled() && physicalSequence ) { - final String databaseSequenceName = physicalNamingStrategy - .toPhysicalSequenceName( sequenceName.getObjectName(), jdbcEnvironment ) - .getText(); + final String databaseSequenceName = physicalNamingStrategy != null + ? physicalNamingStrategy.toPhysicalSequenceName( sequenceName.getObjectName(), jdbcEnvironment ).getText() + : sequenceName.getObjectName().getText(); final Number databaseIncrementValue = isSchemaToBeRecreated( contributor, configurationService ) ? null : getSequenceIncrementValue( jdbcEnvironment, databaseSequenceName ); if ( databaseIncrementValue != null && databaseIncrementValue.intValue() != incrementSize) { final int dbIncrementValue = databaseIncrementValue.intValue();