HHH-18205 respect property-configured naming strategies in Configuration

and make the state model more transparent

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-05-30 23:29:52 +02:00
parent caa0ae845d
commit 407e57d442
1 changed files with 16 additions and 33 deletions

View File

@ -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<UserTypeRegistration> userTypeRegistrations;
private final List<TypeContributor> typeContributorRegistrations = new ArrayList<>();
private final List<FunctionContributor> functionContributorRegistrations = new ArrayList<>();
private Map<String, NamedHqlQueryDefinition> namedQueries;
private Map<String, NamedNativeQueryDefinition> namedSqlQueries;
private Map<String, NamedProcedureCallDefinition> namedProcedureCallMap;
private Map<String, NamedResultSetMappingDescriptor> sqlResultSetMappings;
private Map<String, NamedEntityGraphDefinition> namedEntityGraphMap;
private final Map<String, NamedHqlQueryDefinition> namedQueries = new HashMap<>();
private final Map<String, NamedNativeQueryDefinition> namedSqlQueries = new HashMap<>();
private final Map<String, NamedProcedureCallDefinition> namedProcedureCallMap = new HashMap<>();
private final Map<String, NamedResultSetMappingDescriptor> sqlResultSetMappings = new HashMap<>();
private final Map<String, NamedEntityGraphDefinition> namedEntityGraphMap = new HashMap<>();
private Map<String, SqmFunctionDescriptor> customFunctionDescriptors;
private List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
@ -150,15 +149,14 @@ public class Configuration {
private List<EntityNameResolver> 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<Object> 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~