You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/09/09 23:41:20 UTC

(grails-core) 09/14: Convert grails-data-hibernate7-spring-orm batch 3 to Groovy

This is an automated email from the ASF dual-hosted git repository.

borinquenkid pushed a commit to branch 9.0.x-java-to-groovy
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit bcfb4ec51458cb6e68775cad7e7fb8320c4be98b
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Tue Sep 8 21:32:39 2026 -0500

    Convert grails-data-hibernate7-spring-orm batch 3 to Groovy
    
    Converts HibernateOperations and LocalSessionFactoryBean to @CompileStatic
    Groovy, preserving the upstream Spring copyright headers verbatim.
    
    Verified with codenarcMain/checkstyleMain on spring-orm and the full
    grails-data-hibernate7-core, grails-data-hibernate7 and
    grails-data-hibernate7-spring-boot test suites.
    
    Co-Authored-By: Claude Fable 5.1 <no...@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01E5dsQNQNLuSdFph84RRQdr
---
 ...eOperations.java => HibernateOperations.groovy} | 128 ++++---
 ...oryBean.java => LocalSessionFactoryBean.groovy} | 370 ++++++++++-----------
 2 files changed, 225 insertions(+), 273 deletions(-)

diff --git a/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateOperations.java b/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateOperations.groovy
similarity index 93%
rename from grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateOperations.java
rename to grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateOperations.groovy
index d805b29f87..b1a1c0fd7a 100644
--- a/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateOperations.java
+++ b/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/HibernateOperations.groovy
@@ -13,19 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.grails.orm.hibernate.support.hibernate7
 
-package org.grails.orm.hibernate.support.hibernate7;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-
-import org.hibernate.Filter;
-import org.hibernate.LockMode;
-import org.hibernate.ReplicationMode;
-import org.jspecify.annotations.Nullable;
-
-import org.springframework.dao.DataAccessException;
+import groovy.transform.CompileStatic
+import org.hibernate.Filter
+import org.hibernate.LockMode
+import org.hibernate.ReplicationMode
+import org.springframework.dao.DataAccessException
 
 /**
  * Interface that specifies a common set of Hibernate operations as well as
@@ -59,7 +53,8 @@ import org.springframework.dao.DataAccessException;
  * @see org.hibernate.Session
  * @see HibernateTransactionManager
  */
-public interface HibernateOperations {
+@CompileStatic
+interface HibernateOperations {
 
     /**
      * Execute the action specified by the given action object within a
@@ -80,9 +75,7 @@ public interface HibernateOperations {
      * @see HibernateTransactionManager
      * @see org.hibernate.Session
      */
-    @Nullable
-    <T> T execute(HibernateCallback<T> action) throws DataAccessException;
-
+    def <T> T execute(HibernateCallback<T> action) throws DataAccessException
 
     //-------------------------------------------------------------------------
     // Convenience methods for loading individual objects
@@ -102,8 +95,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#get(Class, Object)
      */
-    @Nullable
-    <T> T get(Class<T> entityClass, Serializable id) throws DataAccessException;
+    def <T> T get(Class<T> entityClass, Serializable id) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -121,8 +113,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#get(Class, Object, org.hibernate.LockOptions)
      */
-    @Nullable
-    <T> T get(Class<T> entityClass, Serializable id, LockMode lockMode) throws DataAccessException;
+    def <T> T get(Class<T> entityClass, Serializable id, LockMode lockMode) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -137,8 +128,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#get(String, Object)
      */
-    @Nullable
-    Object get(String entityName, Serializable id) throws DataAccessException;
+    Object get(String entityName, Serializable id) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -155,8 +145,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#get(String, Object, org.hibernate.LockOptions)
      */
-    @Nullable
-    Object get(String entityName, Serializable id, LockMode lockMode) throws DataAccessException;
+    Object get(String entityName, Serializable id, LockMode lockMode) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -173,7 +162,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#getReference(Class, Object)
      */
-    <T> T load(Class<T> entityClass, Serializable id) throws DataAccessException;
+    def <T> T load(Class<T> entityClass, Serializable id) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -192,7 +181,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#get(Class, Object, org.hibernate.LockOptions)
      */
-    <T> T load(Class<T> entityClass, Serializable id, LockMode lockMode) throws DataAccessException;
+    def <T> T load(Class<T> entityClass, Serializable id, LockMode lockMode) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -208,7 +197,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#getReference(String, Object)
      */
-    Object load(String entityName, Serializable id) throws DataAccessException;
+    Object load(String entityName, Serializable id) throws DataAccessException
 
     /**
      * Return the persistent instance of the given entity class
@@ -226,7 +215,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#get(String, Object, org.hibernate.LockOptions)
      */
-    Object load(String entityName, Serializable id, LockMode lockMode) throws DataAccessException;
+    Object load(String entityName, Serializable id, LockMode lockMode) throws DataAccessException
 
     /**
      * Load the persistent instance with the given identifier
@@ -241,7 +230,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#getIdentifier(Object)
      */
-    void load(Object entity, Serializable id) throws DataAccessException;
+    void load(Object entity, Serializable id) throws DataAccessException
 
     /**
      * Re-read the state of the given persistent instance.
@@ -249,7 +238,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#refresh(Object)
      */
-    void refresh(Object entity) throws DataAccessException;
+    void refresh(Object entity) throws DataAccessException
 
     /**
      * Re-read the state of the given persistent instance.
@@ -259,7 +248,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#refresh(Object, org.hibernate.LockOptions)
      */
-    void refresh(Object entity, LockMode lockMode) throws DataAccessException;
+    void refresh(Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Check whether the given object is in the Session cache.
@@ -268,7 +257,7 @@ public interface HibernateOperations {
      * @throws DataAccessException if there is a Hibernate error
      * @see org.hibernate.Session#contains(Object)
      */
-    boolean contains(Object entity) throws DataAccessException;
+    boolean contains(Object entity) throws DataAccessException
 
     /**
      * Remove the given object from the {@link org.hibernate.Session} cache.
@@ -276,7 +265,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#evict(Object)
      */
-    void evict(Object entity) throws DataAccessException;
+    void evict(Object entity) throws DataAccessException
 
     /**
      * Force initialization of a Hibernate proxy or persistent collection.
@@ -285,7 +274,7 @@ public interface HibernateOperations {
      * because it is not associated with an active Session
      * @see org.hibernate.Hibernate#initialize(Object)
      */
-    void initialize(Object proxy) throws DataAccessException;
+    void initialize(Object proxy) throws DataAccessException
 
     /**
      * Return an enabled Hibernate {@link Filter} for the given filter name.
@@ -296,8 +285,7 @@ public interface HibernateOperations {
      * @throws IllegalStateException if we are not running within a
      * transactional Session (in which case this operation does not make sense)
      */
-    Filter enableFilter(String filterName) throws IllegalStateException;
-
+    Filter enableFilter(String filterName) throws IllegalStateException
 
     //-------------------------------------------------------------------------
     // Convenience methods for storing individual objects
@@ -312,8 +300,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#lock(Object, LockMode)
      */
-    @SuppressWarnings("checkstyle:EmptyLineSeparator")
-    void lock(Object entity, LockMode lockMode) throws DataAccessException;
+    void lock(Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Obtain the specified lock level upon the given object, implicitly
@@ -325,7 +312,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#lock(Object, LockMode)
      */
-    void lock(String entityName, Object entity, LockMode lockMode) throws DataAccessException;
+    void lock(String entityName, Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Persist the given transient instance.
@@ -334,7 +321,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#persist(Object)
      */
-    Serializable save(Object entity) throws DataAccessException;
+    Serializable save(Object entity) throws DataAccessException
 
     /**
      * Persist the given transient instance.
@@ -344,7 +331,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#persist(String, Object)
      */
-    Serializable save(String entityName, Object entity) throws DataAccessException;
+    Serializable save(String entityName, Object entity) throws DataAccessException
 
     /**
      * Update the given persistent instance,
@@ -353,7 +340,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#merge(Object)
      */
-    void update(Object entity) throws DataAccessException;
+    void update(Object entity) throws DataAccessException
 
     /**
      * Update the given persistent instance,
@@ -366,7 +353,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#merge(Object)
      */
-    void update(Object entity, LockMode lockMode) throws DataAccessException;
+    void update(Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Update the given persistent instance,
@@ -376,7 +363,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#merge(String, Object)
      */
-    void update(String entityName, Object entity) throws DataAccessException;
+    void update(String entityName, Object entity) throws DataAccessException
 
     /**
      * Update the given persistent instance,
@@ -390,7 +377,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#merge(String, Object)
      */
-    void update(String entityName, Object entity, LockMode lockMode) throws DataAccessException;
+    void update(String entityName, Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Save or update the given persistent instance,
@@ -402,7 +389,7 @@ public interface HibernateOperations {
      * @see org.hibernate.Session#persist(Object)
      * @see org.hibernate.Session#merge(Object)
      */
-    void saveOrUpdate(Object entity) throws DataAccessException;
+    void saveOrUpdate(Object entity) throws DataAccessException
 
     /**
      * Save or update the given persistent instance,
@@ -415,7 +402,7 @@ public interface HibernateOperations {
      * @see org.hibernate.Session#persist(String, Object)
      * @see org.hibernate.Session#merge(String, Object)
      */
-    void saveOrUpdate(String entityName, Object entity) throws DataAccessException;
+    void saveOrUpdate(String entityName, Object entity) throws DataAccessException
 
     /**
      * Persist the state of the given detached instance according to the
@@ -425,7 +412,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#replicate(Object, ReplicationMode)
      */
-    void replicate(Object entity, ReplicationMode replicationMode) throws DataAccessException;
+    void replicate(Object entity, ReplicationMode replicationMode) throws DataAccessException
 
     /**
      * Persist the state of the given detached instance according to the
@@ -436,7 +423,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#replicate(String, Object, ReplicationMode)
      */
-    void replicate(String entityName, Object entity, ReplicationMode replicationMode) throws DataAccessException;
+    void replicate(String entityName, Object entity, ReplicationMode replicationMode) throws DataAccessException
 
     /**
      * Persist the given transient instance. Follows JSR-220 semantics.
@@ -447,7 +434,7 @@ public interface HibernateOperations {
      * @see org.hibernate.Session#persist(Object)
      * @see #save
      */
-    void persist(Object entity) throws DataAccessException;
+    void persist(Object entity) throws DataAccessException
 
     /**
      * Persist the given transient instance. Follows JSR-220 semantics.
@@ -459,7 +446,7 @@ public interface HibernateOperations {
      * @see org.hibernate.Session#persist(String, Object)
      * @see #save
      */
-    void persist(String entityName, Object entity) throws DataAccessException;
+    void persist(String entityName, Object entity) throws DataAccessException
 
     /**
      * Copy the state of the given object onto the persistent object
@@ -479,7 +466,7 @@ public interface HibernateOperations {
      * @see org.hibernate.Session#merge(Object)
      * @see #saveOrUpdate
      */
-    <T> T merge(T entity) throws DataAccessException;
+    def <T> T merge(T entity) throws DataAccessException
 
     /**
      * Copy the state of the given object onto the persistent object
@@ -500,7 +487,7 @@ public interface HibernateOperations {
      * @see org.hibernate.Session#merge(String, Object)
      * @see #saveOrUpdate
      */
-    <T> T merge(String entityName, T entity) throws DataAccessException;
+    def <T> T merge(String entityName, T entity) throws DataAccessException
 
     /**
      * Delete the given persistent instance.
@@ -508,7 +495,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#remove(Object)
      */
-    void delete(Object entity) throws DataAccessException;
+    void delete(Object entity) throws DataAccessException
 
     /**
      * Delete the given persistent instance.
@@ -520,7 +507,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#remove(Object)
      */
-    void delete(Object entity, LockMode lockMode) throws DataAccessException;
+    void delete(Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Delete the given persistent instance.
@@ -529,7 +516,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#remove(Object)
      */
-    void delete(String entityName, Object entity) throws DataAccessException;
+    void delete(String entityName, Object entity) throws DataAccessException
 
     /**
      * Delete the given persistent instance.
@@ -542,7 +529,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#remove(Object)
      */
-    void delete(String entityName, Object entity, LockMode lockMode) throws DataAccessException;
+    void delete(String entityName, Object entity, LockMode lockMode) throws DataAccessException
 
     /**
      * Delete all given persistent instances.
@@ -552,7 +539,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#remove(Object)
      */
-    void deleteAll(Collection<?> entities) throws DataAccessException;
+    void deleteAll(Collection<?> entities) throws DataAccessException
 
     /**
      * Flush all pending saves, updates and deletes to the database.
@@ -563,7 +550,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#flush()
      */
-    void flush() throws DataAccessException;
+    void flush() throws DataAccessException
 
     /**
      * Remove all objects from the {@link org.hibernate.Session} cache, and
@@ -571,8 +558,7 @@ public interface HibernateOperations {
      * @throws DataAccessException in case of Hibernate errors
      * @see org.hibernate.Session#clear()
      */
-    void clear() throws DataAccessException;
-
+    void clear() throws DataAccessException
 
     //-------------------------------------------------------------------------
     // Convenience finder methods for HQL strings
@@ -590,7 +576,7 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    List<?> find(String queryString, Object... values) throws DataAccessException;
+    List<?> find(String queryString, Object... values) throws DataAccessException
 
     /**
      * Execute an HQL query, binding one value to a ":" named parameter
@@ -605,7 +591,7 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    List<?> findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException;
+    List<?> findByNamedParam(String queryString, String paramName, Object value) throws DataAccessException
 
     /**
      * Execute an HQL query, binding a number of values to ":" named
@@ -620,7 +606,7 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    List<?> findByNamedParam(String queryString, String[] paramNames, Object[] values) throws DataAccessException;
+    List<?> findByNamedParam(String queryString, String[] paramNames, Object[] values) throws DataAccessException
 
     /**
      * Execute an HQL query, binding the properties of the given bean to
@@ -635,8 +621,7 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    List<?> findByValueBean(String queryString, Object valueBean) throws DataAccessException;
-
+    List<?> findByValueBean(String queryString, Object valueBean) throws DataAccessException
 
     //-------------------------------------------------------------------------
     // Convenience finder methods for named queries
@@ -655,7 +640,7 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    List<?> findByNamedQuery(String queryName, Object... values) throws DataAccessException;
+    List<?> findByNamedQuery(String queryName, Object... values) throws DataAccessException
 
     /**
      * Execute a named query, binding one value to a ":" named parameter
@@ -672,7 +657,7 @@ public interface HibernateOperations {
      */
     @Deprecated
     List<?> findByNamedQueryAndNamedParam(String queryName, String paramName, Object value)
-            throws DataAccessException;
+            throws DataAccessException
 
     /**
      * Execute a named query, binding a number of values to ":" named
@@ -689,7 +674,7 @@ public interface HibernateOperations {
      */
     @Deprecated
     List<?> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values)
-            throws DataAccessException;
+            throws DataAccessException
 
     /**
      * Execute a named query, binding the properties of the given bean to
@@ -705,8 +690,7 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    List<?> findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException;
-
+    List<?> findByNamedQueryAndValueBean(String queryName, Object valueBean) throws DataAccessException
 
     //-------------------------------------------------------------------------
     // Convenience query methods for iteration and bulk updates/deletes
@@ -725,6 +709,6 @@ public interface HibernateOperations {
      * lambda code block passed to the general {@link #execute} method
      */
     @Deprecated
-    int bulkUpdate(String queryString, Object... values) throws DataAccessException;
+    int bulkUpdate(String queryString, Object... values) throws DataAccessException
 
 }
diff --git a/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/LocalSessionFactoryBean.java b/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/LocalSessionFactoryBean.groovy
similarity index 67%
rename from grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/LocalSessionFactoryBean.java
rename to grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/LocalSessionFactoryBean.groovy
index 0421b87bf0..64a516fe92 100644
--- a/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/LocalSessionFactoryBean.java
+++ b/grails-data-hibernate7/spring-orm/src/main/groovy/org/grails/orm/hibernate/support/hibernate7/LocalSessionFactoryBean.groovy
@@ -13,45 +13,39 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
-package org.grails.orm.hibernate.support.hibernate7;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import org.hibernate.Interceptor;
-import org.hibernate.SessionFactory;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
-import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
-import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
-import org.hibernate.cache.spi.RegionFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
-import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
-import org.hibernate.integrator.spi.Integrator;
-import org.jspecify.annotations.Nullable;
-
-import org.springframework.beans.factory.BeanFactory;
-import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.FactoryBean;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.SmartInitializingSingleton;
-import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.context.ResourceLoaderAware;
-import org.springframework.core.InfrastructureProxy;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.ResourceLoader;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.core.io.support.ResourcePatternUtils;
-import org.springframework.core.task.AsyncTaskExecutor;
-import org.springframework.core.type.filter.TypeFilter;
+package org.grails.orm.hibernate.support.hibernate7
+
+import javax.sql.DataSource
+
+import groovy.transform.CompileStatic
+import org.hibernate.Interceptor
+import org.hibernate.SessionFactory
+import org.hibernate.boot.MetadataSources
+import org.hibernate.boot.model.naming.ImplicitNamingStrategy
+import org.hibernate.boot.model.naming.PhysicalNamingStrategy
+import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder
+import org.hibernate.cache.spi.RegionFactory
+import org.hibernate.cfg.Configuration
+import org.hibernate.context.spi.CurrentTenantIdentifierResolver
+import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider
+import org.hibernate.integrator.spi.Integrator
+import org.springframework.beans.factory.BeanFactory
+import org.springframework.beans.factory.BeanFactoryAware
+import org.springframework.beans.factory.DisposableBean
+import org.springframework.beans.factory.FactoryBean
+import org.springframework.beans.factory.InitializingBean
+import org.springframework.beans.factory.SmartInitializingSingleton
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory
+import org.springframework.context.ResourceLoaderAware
+import org.springframework.core.InfrastructureProxy
+import org.springframework.core.io.ClassPathResource
+import org.springframework.core.io.Resource
+import org.springframework.core.io.ResourceLoader
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver
+import org.springframework.core.io.support.ResourcePatternResolver
+import org.springframework.core.io.support.ResourcePatternUtils
+import org.springframework.core.task.AsyncTaskExecutor
+import org.springframework.core.type.filter.TypeFilter
 
 /**
  * {@link FactoryBean} that creates a Hibernate {@link SessionFactory}. This is the usual
@@ -75,89 +69,64 @@ import org.springframework.core.type.filter.TypeFilter;
  * @see LocalSessionFactoryBuilder
  * @see org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean
  */
-public class LocalSessionFactoryBean extends HibernateExceptionTranslator
+@CompileStatic
+class LocalSessionFactoryBean extends HibernateExceptionTranslator
         implements FactoryBean<SessionFactory>, ResourceLoaderAware, BeanFactoryAware,
         InitializingBean, SmartInitializingSingleton, DisposableBean {
 
-    @Nullable
-    private DataSource dataSource;
+    private DataSource dataSource
 
-    @Nullable
-    private Resource[] configLocations;
+    private Resource[] configLocations
 
-    @Nullable
-    private String[] mappingResources;
+    private String[] mappingResources
 
-    @Nullable
-    private Resource[] mappingLocations;
+    private Resource[] mappingLocations
 
-    @Nullable
-    private Resource[] cacheableMappingLocations;
+    private Resource[] cacheableMappingLocations
 
-    @Nullable
-    private Resource[] mappingJarLocations;
+    private Resource[] mappingJarLocations
 
-    @Nullable
-    private Resource[] mappingDirectoryLocations;
+    private Resource[] mappingDirectoryLocations
 
-    @Nullable
-    private Interceptor entityInterceptor;
+    private Interceptor entityInterceptor
 
-    @Nullable
-    private ImplicitNamingStrategy implicitNamingStrategy;
+    private ImplicitNamingStrategy implicitNamingStrategy
 
-    @Nullable
-    private PhysicalNamingStrategy physicalNamingStrategy;
+    private PhysicalNamingStrategy physicalNamingStrategy
 
-    @Nullable
-    private Object jtaTransactionManager;
+    private Object jtaTransactionManager
 
-    @Nullable
-    private RegionFactory cacheRegionFactory;
+    private RegionFactory cacheRegionFactory
 
-    @Nullable
-    private MultiTenantConnectionProvider multiTenantConnectionProvider;
+    private MultiTenantConnectionProvider multiTenantConnectionProvider
 
-    @Nullable
-    private CurrentTenantIdentifierResolver currentTenantIdentifierResolver;
+    private CurrentTenantIdentifierResolver currentTenantIdentifierResolver
 
-    @Nullable
-    private Properties hibernateProperties;
+    private Properties hibernateProperties
 
-    @Nullable
-    private TypeFilter[] entityTypeFilters;
+    private TypeFilter[] entityTypeFilters
 
-    @Nullable
-    private Class<?>[] annotatedClasses;
+    private Class<?>[] annotatedClasses
 
-    @Nullable
-    private String[] annotatedPackages;
+    private String[] annotatedPackages
 
-    @Nullable
-    private String[] packagesToScan;
+    private String[] packagesToScan
 
-    @Nullable
-    private AsyncTaskExecutor bootstrapExecutor;
+    private AsyncTaskExecutor bootstrapExecutor
 
-    @Nullable
-    private Integrator[] hibernateIntegrators;
+    private Integrator[] hibernateIntegrators
 
-    private boolean metadataSourcesAccessed = false;
+    private boolean metadataSourcesAccessed = false
 
-    @Nullable
-    private MetadataSources metadataSources;
+    private MetadataSources metadataSources
 
-    @Nullable
-    private ResourcePatternResolver resourcePatternResolver;
+    private ResourcePatternResolver resourcePatternResolver
 
-    @Nullable
-    private ConfigurableListableBeanFactory beanFactory;
+    private ConfigurableListableBeanFactory beanFactory
 
-    @Nullable
-    private Configuration configuration;
+    private Configuration configuration
 
-    @Nullable
-    private SessionFactory sessionFactory;
+    private SessionFactory sessionFactory
 
     /**
      * Set the DataSource to be used by the SessionFactory.
@@ -165,8 +134,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * <p>If this is set, the Hibernate settings should not define
      * a connection provider to avoid meaningless double configuration.
      */
-    public void setDataSource(DataSource dataSource) {
-        this.dataSource = dataSource;
+    void setDataSource(DataSource dataSource) {
+        this.dataSource = dataSource
     }
 
     /**
@@ -176,8 +145,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * resources are specified locally via this bean.
      * @see Configuration#configure(java.net.URL)
      */
-    public void setConfigLocation(Resource configLocation) {
-        this.configLocations = new Resource[] {configLocation};
+    void setConfigLocation(Resource configLocation) {
+        this.configLocations = [configLocation] as Resource[]
     }
 
     /**
@@ -187,8 +156,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * resources are specified locally via this bean.
      * @see Configuration#configure(java.net.URL)
      */
-    public void setConfigLocations(Resource... configLocations) {
-        this.configLocations = configLocations;
+    void setConfigLocations(Resource... configLocations) {
+        this.configLocations = configLocations
     }
 
     /**
@@ -201,8 +170,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @see #setMappingLocations
      * @see Configuration#addResource
      */
-    public void setMappingResources(String... mappingResources) {
-        this.mappingResources = mappingResources;
+    void setMappingResources(String... mappingResources) {
+        this.mappingResources = mappingResources
     }
 
     /**
@@ -214,8 +183,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * or to specify all mappings locally.
      * @see Configuration#addInputStream
      */
-    public void setMappingLocations(Resource... mappingLocations) {
-        this.mappingLocations = mappingLocations;
+    void setMappingLocations(Resource... mappingLocations) {
+        this.mappingLocations = mappingLocations
     }
 
     /**
@@ -227,8 +196,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * or to specify all mappings locally.
      * @see Configuration#addCacheableFile(File)
      */
-    public void setCacheableMappingLocations(Resource... cacheableMappingLocations) {
-        this.cacheableMappingLocations = cacheableMappingLocations;
+    void setCacheableMappingLocations(Resource... cacheableMappingLocations) {
+        this.cacheableMappingLocations = cacheableMappingLocations
     }
 
     /**
@@ -238,8 +207,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * or to specify all mappings locally.
      * @see Configuration#addJar(File)
      */
-    public void setMappingJarLocations(Resource... mappingJarLocations) {
-        this.mappingJarLocations = mappingJarLocations;
+    void setMappingJarLocations(Resource... mappingJarLocations) {
+        this.mappingJarLocations = mappingJarLocations
     }
 
     /**
@@ -249,8 +218,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * or to specify all mappings locally.
      * @see Configuration#addDirectory(File)
      */
-    public void setMappingDirectoryLocations(Resource... mappingDirectoryLocations) {
-        this.mappingDirectoryLocations = mappingDirectoryLocations;
+    void setMappingDirectoryLocations(Resource... mappingDirectoryLocations) {
+        this.mappingDirectoryLocations = mappingDirectoryLocations
     }
 
     /**
@@ -259,24 +228,24 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * Will get applied to any new Session created by this factory.
      * @see Configuration#setInterceptor
      */
-    public void setEntityInterceptor(Interceptor entityInterceptor) {
-        this.entityInterceptor = entityInterceptor;
+    void setEntityInterceptor(Interceptor entityInterceptor) {
+        this.entityInterceptor = entityInterceptor
     }
 
     /**
      * Set a Hibernate 5 {@link ImplicitNamingStrategy} for the SessionFactory.
      * @see Configuration#setImplicitNamingStrategy
      */
-    public void setImplicitNamingStrategy(ImplicitNamingStrategy implicitNamingStrategy) {
-        this.implicitNamingStrategy = implicitNamingStrategy;
+    void setImplicitNamingStrategy(ImplicitNamingStrategy implicitNamingStrategy) {
+        this.implicitNamingStrategy = implicitNamingStrategy
     }
 
     /**
      * Set a Hibernate 5 {@link PhysicalNamingStrategy} for the SessionFactory.
      * @see Configuration#setPhysicalNamingStrategy
      */
-    public void setPhysicalNamingStrategy(PhysicalNamingStrategy physicalNamingStrategy) {
-        this.physicalNamingStrategy = physicalNamingStrategy;
+    void setPhysicalNamingStrategy(PhysicalNamingStrategy physicalNamingStrategy) {
+        this.physicalNamingStrategy = physicalNamingStrategy
     }
 
     /**
@@ -285,8 +254,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * if any. Implicitly sets up {@code JtaPlatform}.
      * @see LocalSessionFactoryBuilder#setJtaTransactionManager
      */
-    public void setJtaTransactionManager(Object jtaTransactionManager) {
-        this.jtaTransactionManager = jtaTransactionManager;
+    void setJtaTransactionManager(Object jtaTransactionManager) {
+        this.jtaTransactionManager = jtaTransactionManager
     }
 
     /**
@@ -297,8 +266,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @since 5.1
      * @see LocalSessionFactoryBuilder#setCacheRegionFactory
      */
-    public void setCacheRegionFactory(RegionFactory cacheRegionFactory) {
-        this.cacheRegionFactory = cacheRegionFactory;
+    void setCacheRegionFactory(RegionFactory cacheRegionFactory) {
+        this.cacheRegionFactory = cacheRegionFactory
     }
 
     /**
@@ -306,16 +275,16 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @since 4.3
      * @see LocalSessionFactoryBuilder#setMultiTenantConnectionProvider
      */
-    public void setMultiTenantConnectionProvider(MultiTenantConnectionProvider multiTenantConnectionProvider) {
-        this.multiTenantConnectionProvider = multiTenantConnectionProvider;
+    void setMultiTenantConnectionProvider(MultiTenantConnectionProvider multiTenantConnectionProvider) {
+        this.multiTenantConnectionProvider = multiTenantConnectionProvider
     }
 
     /**
      * Set a {@link CurrentTenantIdentifierResolver} to be passed on to the SessionFactory.
      * @see LocalSessionFactoryBuilder#setCurrentTenantIdentifierResolver
      */
-    public void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver currentTenantIdentifierResolver) {
-        this.currentTenantIdentifierResolver = currentTenantIdentifierResolver;
+    void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver currentTenantIdentifierResolver) {
+        this.currentTenantIdentifierResolver = currentTenantIdentifierResolver
     }
 
     /**
@@ -325,19 +294,19 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * provider settings and use a Spring-set DataSource instead.
      * @see #setDataSource
      */
-    public void setHibernateProperties(Properties hibernateProperties) {
-        this.hibernateProperties = hibernateProperties;
+    void setHibernateProperties(Properties hibernateProperties) {
+        this.hibernateProperties = hibernateProperties
     }
 
     /**
      * Return the Hibernate properties, if any. Mainly available for
      * configuration through property paths that specify individual keys.
      */
-    public Properties getHibernateProperties() {
+    Properties getHibernateProperties() {
         if (this.hibernateProperties == null) {
-            this.hibernateProperties = new Properties();
+            this.hibernateProperties = new Properties()
         }
-        return this.hibernateProperties;
+        return this.hibernateProperties
     }
 
     /**
@@ -347,16 +316,16 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * or {@code @jakarta.persistence.MappedSuperclass}.
      * @see #setPackagesToScan
      */
-    public void setEntityTypeFilters(TypeFilter... entityTypeFilters) {
-        this.entityTypeFilters = entityTypeFilters;
+    void setEntityTypeFilters(TypeFilter... entityTypeFilters) {
+        this.entityTypeFilters = entityTypeFilters
     }
 
     /**
      * Specify annotated entity classes to register with this Hibernate SessionFactory.
      * @see Configuration#addAnnotatedClass(Class)
      */
-    public void setAnnotatedClasses(Class<?>... annotatedClasses) {
-        this.annotatedClasses = annotatedClasses;
+    void setAnnotatedClasses(Class<?>... annotatedClasses) {
+        this.annotatedClasses = annotatedClasses
     }
 
     /**
@@ -364,8 +333,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * annotation metadata will be read.
      * @see Configuration#addPackage(String)
      */
-    public void setAnnotatedPackages(String... annotatedPackages) {
-        this.annotatedPackages = annotatedPackages;
+    void setAnnotatedPackages(String... annotatedPackages) {
+        this.annotatedPackages = annotatedPackages
     }
 
     /**
@@ -373,8 +342,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * classpath. This is analogous to Spring's component-scan feature
      * ({@link org.springframework.context.annotation.ClassPathBeanDefinitionScanner}).
      */
-    public void setPackagesToScan(String... packagesToScan) {
-        this.packagesToScan = packagesToScan;
+    void setPackagesToScan(String... packagesToScan) {
+        this.packagesToScan = packagesToScan
     }
 
     /**
@@ -392,8 +361,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @since 4.3
      * @see LocalSessionFactoryBuilder#buildSessionFactory(AsyncTaskExecutor)
      */
-    public void setBootstrapExecutor(AsyncTaskExecutor bootstrapExecutor) {
-        this.bootstrapExecutor = bootstrapExecutor;
+    void setBootstrapExecutor(AsyncTaskExecutor bootstrapExecutor) {
+        this.bootstrapExecutor = bootstrapExecutor
     }
 
     /**
@@ -405,8 +374,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @see #setMetadataSources
      * @see BootstrapServiceRegistryBuilder#applyIntegrator
      */
-    public void setHibernateIntegrators(Integrator... hibernateIntegrators) {
-        this.hibernateIntegrators = hibernateIntegrators;
+    void setHibernateIntegrators(Integrator... hibernateIntegrators) {
+        this.hibernateIntegrators = hibernateIntegrators
     }
 
     /**
@@ -417,9 +386,9 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @see MetadataSources#MetadataSources(ServiceRegistry)
      * @see BootstrapServiceRegistryBuilder#build()
      */
-    public void setMetadataSources(MetadataSources metadataSources) {
-        this.metadataSourcesAccessed = true;
-        this.metadataSources = metadataSources;
+    void setMetadataSources(MetadataSources metadataSources) {
+        this.metadataSourcesAccessed = true
+        this.metadataSources = metadataSources
     }
 
     /**
@@ -430,21 +399,21 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @since 4.3
      * @see LocalSessionFactoryBuilder#LocalSessionFactoryBuilder(DataSource, ResourceLoader, MetadataSources)
      */
-    public MetadataSources getMetadataSources() {
-        this.metadataSourcesAccessed = true;
+    MetadataSources getMetadataSources() {
+        this.metadataSourcesAccessed = true
         if (this.metadataSources == null) {
-            BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder();
+            BootstrapServiceRegistryBuilder builder = new BootstrapServiceRegistryBuilder()
             if (this.resourcePatternResolver != null) {
-                builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader());
+                builder = builder.applyClassLoader(this.resourcePatternResolver.getClassLoader())
             }
             if (this.hibernateIntegrators != null) {
                 for (Integrator integrator : this.hibernateIntegrators) {
-                    builder = builder.applyIntegrator(integrator);
+                    builder = builder.applyIntegrator(integrator)
                 }
             }
-            this.metadataSources = new MetadataSources(builder.build());
+            this.metadataSources = new MetadataSources(builder.build())
         }
-        return this.metadataSources;
+        return this.metadataSources
     }
 
     /**
@@ -452,8 +421,8 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @param resourceLoader the ResourceLoader to use (never {@code null})
      */
     @Override
-    public void setResourceLoader(ResourceLoader resourceLoader) {
-        this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader);
+    void setResourceLoader(ResourceLoader resourceLoader) {
+        this.resourcePatternResolver = ResourcePatternUtils.getResourcePatternResolver(resourceLoader)
     }
 
     /**
@@ -461,11 +430,11 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @return the ResourceLoader to use (never {@code null})
      * @since 4.3
      */
-    public ResourceLoader getResourceLoader() {
+    ResourceLoader getResourceLoader() {
         if (this.resourcePatternResolver == null) {
-            this.resourcePatternResolver = new PathMatchingResourcePatternResolver();
+            this.resourcePatternResolver = new PathMatchingResourcePatternResolver()
         }
-        return this.resourcePatternResolver;
+        return this.resourcePatternResolver
     }
 
     /**
@@ -477,132 +446,132 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * @see LocalSessionFactoryBuilder#setBeanContainer
      */
     @Override
-    public void setBeanFactory(BeanFactory beanFactory) {
-        if (beanFactory instanceof ConfigurableListableBeanFactory clbf) {
-            this.beanFactory = clbf;
+    void setBeanFactory(BeanFactory beanFactory) {
+        if (beanFactory instanceof ConfigurableListableBeanFactory) {
+            this.beanFactory = (ConfigurableListableBeanFactory) beanFactory
         }
     }
 
     @Override
-    public void afterPropertiesSet() throws IOException {
+    void afterPropertiesSet() throws IOException {
         if (this.metadataSources != null && !this.metadataSourcesAccessed) {
             // Repeated initialization with no user-customized MetadataSources -> clear it.
-            this.metadataSources = null;
+            this.metadataSources = null
         }
 
         LocalSessionFactoryBuilder sfb = new LocalSessionFactoryBuilder(
-                this.dataSource, getResourceLoader(), getMetadataSources());
+                this.dataSource, getResourceLoader(), getMetadataSources())
 
         if (this.configLocations != null) {
             for (Resource resource : this.configLocations) {
                 // Load Hibernate configuration from given location.
-                sfb.configure(resource.getURL());
+                sfb.configure(resource.getURL())
             }
         }
 
         if (this.mappingResources != null) {
             // Register given Hibernate mapping definitions, contained in resource files.
             for (String mapping : this.mappingResources) {
-                Resource mr = new ClassPathResource(mapping.trim(), getResourceLoader().getClassLoader());
-                sfb.addInputStream(mr.getInputStream());
+                Resource mr = new ClassPathResource(mapping.trim(), getResourceLoader().getClassLoader())
+                sfb.addInputStream(mr.getInputStream())
             }
         }
 
         if (this.mappingLocations != null) {
             // Register given Hibernate mapping definitions, contained in resource files.
             for (Resource resource : this.mappingLocations) {
-                sfb.addInputStream(resource.getInputStream());
+                sfb.addInputStream(resource.getInputStream())
             }
         }
 
         if (this.cacheableMappingLocations != null) {
             // Register given cacheable Hibernate mapping definitions, read from the file system.
             for (Resource resource : this.cacheableMappingLocations) {
-                sfb.addCacheableFile(resource.getFile());
+                sfb.addCacheableFile(resource.getFile())
             }
         }
 
         if (this.mappingJarLocations != null) {
             // Register given Hibernate mapping definitions, contained in jar files.
             for (Resource resource : this.mappingJarLocations) {
-                sfb.addJar(resource.getFile());
+                sfb.addJar(resource.getFile())
             }
         }
 
         if (this.mappingDirectoryLocations != null) {
             // Register all Hibernate mapping definitions in the given directories.
             for (Resource resource : this.mappingDirectoryLocations) {
-                File file = resource.getFile();
+                File file = resource.getFile()
                 if (!file.isDirectory()) {
                     throw new IllegalArgumentException(
-                            "Mapping directory location [" + resource + "] does not denote a directory");
+                            'Mapping directory location [' + resource + '] does not denote a directory')
                 }
-                sfb.addDirectory(file);
+                sfb.addDirectory(file)
             }
         }
 
         if (this.entityInterceptor != null) {
-            sfb.setInterceptor(this.entityInterceptor);
+            sfb.setInterceptor(this.entityInterceptor)
         }
 
         if (this.implicitNamingStrategy != null) {
-            sfb.setImplicitNamingStrategy(this.implicitNamingStrategy);
+            sfb.setImplicitNamingStrategy(this.implicitNamingStrategy)
         }
 
         if (this.physicalNamingStrategy != null) {
-            sfb.setPhysicalNamingStrategy(this.physicalNamingStrategy);
+            sfb.setPhysicalNamingStrategy(this.physicalNamingStrategy)
         }
 
         if (this.jtaTransactionManager != null) {
-            sfb.setJtaTransactionManager(this.jtaTransactionManager);
+            sfb.setJtaTransactionManager(this.jtaTransactionManager)
         }
 
         if (this.beanFactory != null) {
-            sfb.setBeanContainer(this.beanFactory);
+            sfb.setBeanContainer(this.beanFactory)
         }
 
         if (this.cacheRegionFactory != null) {
-            sfb.setCacheRegionFactory(this.cacheRegionFactory);
+            sfb.setCacheRegionFactory(this.cacheRegionFactory)
         }
 
         if (this.multiTenantConnectionProvider != null) {
-            sfb.setMultiTenantConnectionProvider(this.multiTenantConnectionProvider);
+            sfb.setMultiTenantConnectionProvider(this.multiTenantConnectionProvider)
         }
 
         if (this.currentTenantIdentifierResolver != null) {
-            sfb.setCurrentTenantIdentifierResolver(this.currentTenantIdentifierResolver);
+            sfb.setCurrentTenantIdentifierResolver(this.currentTenantIdentifierResolver)
         }
 
         if (this.hibernateProperties != null) {
-            sfb.addProperties(this.hibernateProperties);
+            sfb.addProperties(this.hibernateProperties)
         }
 
         if (this.entityTypeFilters != null) {
-            sfb.setEntityTypeFilters(this.entityTypeFilters);
+            sfb.setEntityTypeFilters(this.entityTypeFilters)
         }
 
         if (this.annotatedClasses != null) {
-            sfb.addAnnotatedClasses(this.annotatedClasses);
+            sfb.addAnnotatedClasses(this.annotatedClasses)
         }
 
         if (this.annotatedPackages != null) {
-            sfb.addPackages(this.annotatedPackages);
+            sfb.addPackages(this.annotatedPackages)
         }
 
         if (this.packagesToScan != null) {
-            sfb.scanPackages(this.packagesToScan);
+            sfb.scanPackages(this.packagesToScan)
         }
 
         // Build SessionFactory instance.
-        this.configuration = sfb;
-        this.sessionFactory = buildSessionFactory(sfb);
+        this.configuration = sfb
+        this.sessionFactory = buildSessionFactory(sfb)
     }
 
     @Override
-    public void afterSingletonsInstantiated() {
+    void afterSingletonsInstantiated() {
         // Enforce completion of asynchronous Hibernate initialization before context refresh completion.
-        if (this.sessionFactory instanceof InfrastructureProxy proxy) {
-            proxy.getWrappedObject();
+        if (this.sessionFactory instanceof InfrastructureProxy) {
+            ((InfrastructureProxy) this.sessionFactory).getWrappedObject()
         }
     }
 
@@ -619,7 +588,7 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      */
     protected SessionFactory buildSessionFactory(LocalSessionFactoryBuilder sfb) {
         return (this.bootstrapExecutor != null ? sfb.buildSessionFactory(this.bootstrapExecutor) :
-                sfb.buildSessionFactory());
+                sfb.buildSessionFactory())
     }
 
     /**
@@ -627,33 +596,32 @@ public class LocalSessionFactoryBean extends HibernateExceptionTranslator
      * Allows for access to configuration metadata stored there (rarely needed).
      * @throws IllegalStateException if the Configuration object has not been initialized yet
      */
-    public final Configuration getConfiguration() {
+    final Configuration getConfiguration() {
         if (this.configuration == null) {
-            throw new IllegalStateException("Configuration not initialized yet");
+            throw new IllegalStateException('Configuration not initialized yet')
         }
-        return this.configuration;
+        return this.configuration
     }
 
     @Override
-    @Nullable
-    public SessionFactory getObject() {
-        return this.sessionFactory;
+    SessionFactory getObject() {
+        return this.sessionFactory
     }
 
     @Override
-    public Class<?> getObjectType() {
-        return (this.sessionFactory != null ? this.sessionFactory.getClass() : SessionFactory.class);
+    Class<?> getObjectType() {
+        return (this.sessionFactory != null ? this.sessionFactory.getClass() : SessionFactory)
     }
 
     @Override
-    public boolean isSingleton() {
-        return true;
+    boolean isSingleton() {
+        return true
     }
 
     @Override
-    public void destroy() {
+    void destroy() {
         if (this.sessionFactory != null) {
-            this.sessionFactory.close();
+            this.sessionFactory.close()
         }
     }