From 7ff2c86c6ebf7822c1b8d30337348ae1dbc3bea8 Mon Sep 17 00:00:00 2001 From: Gavin Date: Fri, 12 May 2023 18:08:42 +0200 Subject: [PATCH] fix incorrect warning the warning was printed even when it should not be (my fault) --- .../dialect/internal/DialectFactoryImpl.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java index 529e469416..a5e5f51ebe 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/dialect/internal/DialectFactoryImpl.java @@ -82,9 +82,9 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS @Override public Dialect buildDialect(Map configValues, DialectResolutionInfoSource resolutionInfoSource) throws HibernateException { final Object dialectReference = configValues.get( AvailableSettings.DIALECT ); - Dialect dialect = !isEmpty( dialectReference ) - ? constructDialect( dialectReference, resolutionInfoSource ) - : determineDialect( resolutionInfoSource ); + Dialect dialect = isEmpty( dialectReference ) + ? determineDialect( resolutionInfoSource ) + : constructDialect( dialectReference, resolutionInfoSource ); logSelectedDialect( dialect ); return dialect; } @@ -103,22 +103,18 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS DEPRECATION_LOGGER.deprecatedDialect( dialectClass.getSimpleName() ); } } - else if ( Dialect.class.getPackage() == dialectClass.getPackage() ) { - DEPRECATION_LOGGER.automaticDialect( dialectClass.getSimpleName() ); - } } - @SuppressWarnings("SimplifiableIfStatement") private boolean isEmpty(Object dialectReference) { - if ( dialectReference != null ) { - // the referenced value is not null - if ( dialectReference instanceof String ) { - // if it is a String, it might still be empty though... - return StringHelper.isEmpty( (String) dialectReference ); - } - return false; + if ( dialectReference == null ) { + return true; + } + else { + // the referenced value is not null + return dialectReference instanceof String + // if it is a String, it might still be empty though... + && StringHelper.isEmpty((String) dialectReference); } - return true; } private Dialect constructDialect(Object dialectReference, DialectResolutionInfoSource resolutionInfoSource) { @@ -152,6 +148,9 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS if ( dialect == null ) { throw new HibernateException( "Unable to construct requested dialect [" + dialectReference + "]" ); } + else if ( Dialect.class.getPackage() == dialect.getClass().getPackage() ) { + DEPRECATION_LOGGER.automaticDialect( dialect.getClass().getSimpleName() ); + } return dialect; } catch (StrategySelectionException e) {