diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index 53c3f3a8ad..d28500ca85 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -37,9 +37,7 @@ import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor; import org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor; import org.hibernate.boot.model.convert.spi.ConverterDescriptor; import org.hibernate.boot.model.naming.ImplicitNamingStrategy; -import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl; import org.hibernate.boot.model.naming.PhysicalNamingStrategy; -import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.boot.query.NamedHqlQueryDefinition; @@ -129,7 +127,8 @@ public class Configuration { private final BootstrapServiceRegistry bootstrapServiceRegistry; private final MetadataSources metadataSources; - private final ClassmateContext classmateContext; + final private StandardServiceRegistryBuilder standardServiceRegistryBuilder; + private final ClassmateContext classmateContext = new ClassmateContext(); // used during processing mappings private ImplicitNamingStrategy implicitNamingStrategy; @@ -138,11 +137,11 @@ public class Configuration { private List userTypeRegistrations; private final List typeContributorRegistrations = new ArrayList<>(); private final List functionContributorRegistrations = new ArrayList<>(); - private Map namedQueries; - private Map namedSqlQueries; - private Map namedProcedureCallMap; - private Map sqlResultSetMappings; - private Map namedEntityGraphMap; + private final Map namedQueries = new HashMap<>(); + private final Map namedSqlQueries = new HashMap<>(); + private final Map namedProcedureCallMap = new HashMap<>(); + private final Map sqlResultSetMappings = new HashMap<>(); + private final Map namedEntityGraphMap = new HashMap<>(); private Map customFunctionDescriptors; private List auxiliaryDatabaseObjectList; @@ -150,15 +149,14 @@ public class Configuration { private List entityNameResolvers = new ArrayList<>(); // used to build SF - private StandardServiceRegistryBuilder standardServiceRegistryBuilder; + private Properties properties = new Properties(); + private Interceptor interceptor = EmptyInterceptor.INSTANCE; private EntityNotFoundDelegate entityNotFoundDelegate; - private Interceptor interceptor; private SessionFactoryObserver sessionFactoryObserver; private StatementInspector statementInspector; private CurrentTenantIdentifierResolver currentTenantIdentifierResolver; private CustomEntityDirtinessStrategy customEntityDirtinessStrategy; private ColumnOrderingStrategy columnOrderingStrategy; - private Properties properties; private SharedCacheMode sharedCacheMode; @Deprecated(since = "6", forRemoval = true) @@ -179,10 +177,10 @@ public class Configuration { * and a newly instantiated {@link MetadataSources}. */ public Configuration(BootstrapServiceRegistry serviceRegistry) { - this.bootstrapServiceRegistry = serviceRegistry; - this.metadataSources = new MetadataSources( serviceRegistry, createMappingBinderAccess( serviceRegistry ) ); - this.classmateContext = new ClassmateContext(); - reset(); + bootstrapServiceRegistry = serviceRegistry; + metadataSources = new MetadataSources( serviceRegistry, createMappingBinderAccess( serviceRegistry ) ); + standardServiceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry ); + properties.putAll( standardServiceRegistryBuilder.getSettings() ); } private XmlMappingBinderAccess createMappingBinderAccess(BootstrapServiceRegistry serviceRegistry) { @@ -197,10 +195,10 @@ public class Configuration { * {@link BootstrapServiceRegistry} obtained from the {@link MetadataSources}. */ public Configuration(MetadataSources metadataSources) { - this.bootstrapServiceRegistry = getBootstrapRegistry( metadataSources.getServiceRegistry() ); this.metadataSources = metadataSources; - this.classmateContext = new ClassmateContext(); - reset(); + bootstrapServiceRegistry = getBootstrapRegistry( metadataSources.getServiceRegistry() ); + standardServiceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry ); + properties.putAll( standardServiceRegistryBuilder.getSettings() ); } private static BootstrapServiceRegistry getBootstrapRegistry(ServiceRegistry serviceRegistry) { @@ -219,21 +217,6 @@ public class Configuration { ); } - protected void reset() { - implicitNamingStrategy = ImplicitNamingStrategyJpaCompliantImpl.INSTANCE; - physicalNamingStrategy = PhysicalNamingStrategyStandardImpl.INSTANCE; - namedQueries = new HashMap<>(); - namedSqlQueries = new HashMap<>(); - sqlResultSetMappings = new HashMap<>(); - namedEntityGraphMap = new HashMap<>(); - namedProcedureCallMap = new HashMap<>(); - - standardServiceRegistryBuilder = new StandardServiceRegistryBuilder( bootstrapServiceRegistry ); - interceptor = EmptyInterceptor.INSTANCE; - properties = new Properties( ); - properties.putAll( standardServiceRegistryBuilder.getSettings() ); - } - // properties/settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~