fix incorrect warning

the warning was printed even when it should not be (my fault)
This commit is contained in:
Gavin 2023-05-12 18:08:42 +02:00 committed by Gavin King
parent cc3a17a972
commit 7ff2c86c6e
1 changed files with 14 additions and 15 deletions

View File

@ -82,9 +82,9 @@ public class DialectFactoryImpl implements DialectFactory, ServiceRegistryAwareS
@Override
public Dialect buildDialect(Map<String,Object> 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) {