diff --git a/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java index 7324b14e3d..b2af24f6c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java @@ -395,25 +395,6 @@ public interface SessionFactoryBuilder { */ SessionFactoryBuilder applyPreferUserTransactions(boolean preferUserTransactions); - /** - * Should we strictly adhere to JPA Query Language (JPQL) syntax, or more broadly support - * all of Hibernate's superset (HQL)? - *

- * Setting this to {@code true} may cause valid HQL to throw an exception because it violates - * the JPQL subset. - * - * @param enabled {@code true} indicates that we should strictly adhere to the JPQL subset; {@code false} - * indicates we should accept the broader HQL syntax. - * - * @return {@code this}, for method chaining - * - * @see org.hibernate.cfg.AvailableSettings#JPAQL_STRICT_COMPLIANCE - * - * @deprecated Use {@link #enableJpaQueryCompliance} instead - */ - @Deprecated - SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled); - /** * Should named queries be checked on startup? * @@ -618,26 +599,10 @@ public interface SessionFactoryBuilder { */ SessionFactoryBuilder applyConnectionHandlingMode(PhysicalConnectionHandlingMode connectionHandlingMode); - /** - * Apply a ConnectionReleaseMode. - * - * @param connectionReleaseMode The ConnectionReleaseMode to use. - * - * @return {@code this}, for method chaining - * - * @see org.hibernate.cfg.AvailableSettings#RELEASE_CONNECTIONS - * - * @deprecated Use {@link #applyConnectionHandlingMode} instead - */ - @Deprecated - SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode); - /** * @see org.hibernate.cfg.AvailableSettings#CONNECTION_PROVIDER_DISABLES_AUTOCOMMIT */ - default SessionFactoryBuilder applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit) { - return this; - } + SessionFactoryBuilder applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit); /** * Should Hibernate apply comments to SQL it generates? @@ -652,15 +617,14 @@ public interface SessionFactoryBuilder { /** * Apply a SQLFunction to the underlying {@link org.hibernate.query.sqm.function.SqmFunctionRegistry}. - *

- * TODO : Ultimately I would like this to move to {@link MetadataBuilder} in conjunction with allowing mappings to reference SQLFunctions. - * today mappings can only name SQL functions directly, not through the SQLFunctionRegistry indirection * * @param registrationName The name to register it under. * @param functionDescriptor The SQLFunction impl * * @return {@code this}, for method chaining */ + // Ultimately I would like this to move to {@link MetadataBuilder} in conjunction with allowing mappings to reference SQLFunctions. + // today mappings can only name SQL functions directly, not through the SQLFunctionRegistry indirection SessionFactoryBuilder applySqlFunction(String registrationName, SqmFunctionDescriptor functionDescriptor); /** diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java index 8e925f87bb..1f695624e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryBuilderImpl.java @@ -349,12 +349,6 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement return this; } - @Override - public SessionFactoryBuilder applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { - this.optionsBuilder.applyConnectionReleaseMode( connectionReleaseMode ); - return this; - } - @Override public SessionFactoryBuilder applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit) { this.optionsBuilder.applyConnectionProviderDisablesAutoCommit( providerDisablesAutoCommit ); @@ -391,13 +385,6 @@ public class SessionFactoryBuilderImpl implements SessionFactoryBuilderImplement return this; } - - @Override - public SessionFactoryBuilder applyStrictJpaQueryLanguageCompliance(boolean enabled) { - this.optionsBuilder.enableStrictJpaQueryLanguageCompliance( enabled ); - return this; - } - @Override public SessionFactoryBuilder enableJpaQueryCompliance(boolean enabled) { this.optionsBuilder.enableJpaQueryCompliance( enabled ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java index fd1d5b0051..c25e08274e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java @@ -17,7 +17,6 @@ import java.util.TimeZone; import java.util.concurrent.Callable; import java.util.function.Supplier; -import org.hibernate.ConnectionAcquisitionMode; import org.hibernate.ConnectionReleaseMode; import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.EmptyInterceptor; @@ -179,12 +178,12 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { private Class statelessInterceptorClass; private Supplier statelessInterceptorSupplier; private StatementInspector statementInspector; - private List sessionFactoryObserverList = new ArrayList<>(); - private BaselineSessionEventsListenerBuilder baselineSessionEventsListenerBuilder; // not exposed on builder atm + private final List sessionFactoryObserverList = new ArrayList<>(); + private final BaselineSessionEventsListenerBuilder baselineSessionEventsListenerBuilder; // not exposed on builder atm // persistence behavior private CustomEntityDirtinessStrategy customEntityDirtinessStrategy; - private List entityNameResolvers = new ArrayList<>(); + private final List entityNameResolvers = new ArrayList<>(); private EntityNotFoundDelegate entityNotFoundDelegate; private boolean identifierRollbackEnabled; private EntityTuplizerFactory entityTuplizerFactory = new EntityTuplizerFactory(); @@ -269,10 +268,8 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); - final Map configurationSettings = new HashMap(); - //noinspection unchecked + final Map configurationSettings = new HashMap<>(); configurationSettings.putAll( jdbcServices.getJdbcEnvironment().getDialect().getDefaultProperties() ); - //noinspection unchecked configurationSettings.putAll( cfgService.getSettings() ); if ( cfgService == null ) { cfgService = new ConfigurationServiceImpl( configurationSettings ); @@ -390,7 +387,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ); this.sqmTranslatorFactory = resolveSqmTranslator( sqmTranslatorFactoryImplFqn, - serviceRegistry, strategySelector ); @@ -572,6 +568,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ); } + @SuppressWarnings("unchecked") private SqmMultiTableMutationStrategy resolveSqmMutationStrategy( String strategyName, StandardServiceRegistry serviceRegistry, @@ -620,6 +617,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ); } + @SuppressWarnings("unchecked") private SqmMultiTableInsertStrategy resolveSqmInsertStrategy( String strategyName, StandardServiceRegistry serviceRegistry, @@ -680,7 +678,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { return strategySelector.resolveDefaultableStrategy( HqlTranslator.class, producerName, - new Callable() { + new Callable<>() { @Override public HqlTranslator call() throws Exception { final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); @@ -692,7 +690,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { private SqmTranslatorFactory resolveSqmTranslator( String translatorImplFqn, - StandardServiceRegistry serviceRegistry, StrategySelector strategySelector) { if ( StringHelper.isEmpty( translatorImplFqn ) ) { return null; @@ -704,8 +701,9 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ); } - @SuppressWarnings("deprecation") - private static Interceptor determineInterceptor(Map configurationSettings, StrategySelector strategySelector) { + private static Interceptor determineInterceptor( + Map configurationSettings, + StrategySelector strategySelector) { Object setting = configurationSettings.get( INTERCEPTOR ); if ( setting == null ) { // try the legacy (deprecated) JPA name @@ -724,9 +722,9 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { ); } - @SuppressWarnings({"unchecked" }) + @SuppressWarnings("unchecked") private static Supplier determineStatelessInterceptor( - Map configurationSettings, + Map configurationSettings, StrategySelector strategySelector) { Object setting = configurationSettings.get( SESSION_SCOPED_INTERCEPTOR ); @@ -763,7 +761,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { } private PhysicalConnectionHandlingMode interpretConnectionHandlingMode( - Map configurationSettings, + Map configurationSettings, StandardServiceRegistry serviceRegistry) { final PhysicalConnectionHandlingMode specifiedHandlingMode = PhysicalConnectionHandlingMode.interpret( configurationSettings.get( CONNECTION_HANDLING ) @@ -930,7 +928,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { @Override public SessionFactoryObserver[] getSessionFactoryObservers() { - return sessionFactoryObserverList.toArray( new SessionFactoryObserver[ sessionFactoryObserverList.size() ] ); + return sessionFactoryObserverList.toArray(new SessionFactoryObserver[0]); } @Override @@ -1120,7 +1118,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { @Override public EntityNameResolver[] getEntityNameResolvers() { - return entityNameResolvers.toArray( new EntityNameResolver[ entityNameResolvers.size() ] ); + return entityNameResolvers.toArray(new EntityNameResolver[0]); } @Override @@ -1410,21 +1408,6 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { this.connectionHandlingMode = mode; } - public void applyConnectionReleaseMode(ConnectionReleaseMode connectionReleaseMode) { - if ( this.connectionHandlingMode == null ) { - this.connectionHandlingMode = PhysicalConnectionHandlingMode.interpret( - ConnectionAcquisitionMode.AS_NEEDED, - connectionReleaseMode - ); - } - else { - this.connectionHandlingMode = PhysicalConnectionHandlingMode.interpret( - this.connectionHandlingMode.getAcquisitionMode(), - connectionReleaseMode - ); - } - } - public void applyConnectionProviderDisablesAutoCommit(boolean providerDisablesAutoCommit) { this.connectionProviderDisablesAutoCommit = providerDisablesAutoCommit; } @@ -1448,16 +1431,12 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { this.releaseResourcesOnCloseEnabled = enable; } - public void enableStrictJpaQueryLanguageCompliance(boolean enabled) { - enableJpaQueryCompliance( enabled ); - } - public void enableJpaQueryCompliance(boolean enabled) { mutableJpaCompliance().setQueryCompliance( enabled ); } private MutableJpaCompliance mutableJpaCompliance() { - if ( ! MutableJpaCompliance.class.isInstance( this.jpaCompliance ) ) { + if ( !(this.jpaCompliance instanceof MutableJpaCompliance) ) { throw new IllegalStateException( "JpaCompliance is no longer mutable" ); } @@ -1506,7 +1485,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions { } public SessionFactoryOptions buildOptions() { - if ( MutableJpaCompliance.class.isInstance( this.jpaCompliance ) ) { + if ( this.jpaCompliance instanceof MutableJpaCompliance ) { this.jpaCompliance = mutableJpaCompliance().immutableCopy(); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java index 7e623eabf5..a1d5faf915 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryBuilder.java @@ -8,7 +8,6 @@ package org.hibernate.boot.spi; import java.util.function.Supplier; -import org.hibernate.ConnectionReleaseMode; import org.hibernate.CustomEntityDirtinessStrategy; import org.hibernate.EntityNameResolver; import org.hibernate.Interceptor; @@ -237,12 +236,6 @@ public abstract class AbstractDelegatingSessionFactoryBuilder * This setting controls whether such a coercion should be allowed. * + * @see org.hibernate.cfg.AvailableSettings#JPA_LOAD_BY_ID_COMPLIANCE + * * @since 6.0 */ boolean isLoadByIdComplianceEnabled();