unexpose the ServiceRegistry on SqmCreationContext + SqlAstCreationContext
This commit is contained in:
parent
25d0922ff9
commit
0c3b8fd819
|
@ -403,4 +403,9 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
|
||||||
public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
|
public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass) {
|
||||||
return delegate.findEntityGraphsByType(entityClass);
|
return delegate.findEntityGraphsByType(entityClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> classForName(String className) {
|
||||||
|
return delegate.classForName( className );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,6 @@ public interface SessionFactoryImplementor
|
||||||
*
|
*
|
||||||
* @return The factory's ServiceRegistry
|
* @return The factory's ServiceRegistry
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
ServiceRegistryImplementor getServiceRegistry();
|
ServiceRegistryImplementor getServiceRegistry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -458,8 +458,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
private static SessionFactoryServiceRegistry getServiceRegistry(
|
private static SessionFactoryServiceRegistry getServiceRegistry(
|
||||||
SessionFactoryOptions options,
|
SessionFactoryOptions options,
|
||||||
SessionFactoryImplementor self) {
|
SessionFactoryImplementor self) {
|
||||||
return options
|
return options.getServiceRegistry()
|
||||||
.getServiceRegistry()
|
|
||||||
.requireService( SessionFactoryServiceRegistryFactory.class )
|
.requireService( SessionFactoryServiceRegistryFactory.class )
|
||||||
// it is not great how we pass in an instance to
|
// it is not great how we pass in an instance to
|
||||||
// an incompletely-initialized instance here:
|
// an incompletely-initialized instance here:
|
||||||
|
@ -1704,6 +1703,12 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
return schemaManager;
|
return schemaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> classForName(String className) {
|
||||||
|
return serviceRegistry.requireService( ClassLoaderService.class )
|
||||||
|
.classForName( className );
|
||||||
|
}
|
||||||
|
|
||||||
private enum Status {
|
private enum Status {
|
||||||
OPEN,
|
OPEN,
|
||||||
CLOSING,
|
CLOSING,
|
||||||
|
|
|
@ -13,7 +13,6 @@ import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
import org.hibernate.metamodel.model.domain.EntityDomainType;
|
||||||
import org.hibernate.query.criteria.JpaSelection;
|
import org.hibernate.query.criteria.JpaSelection;
|
||||||
|
@ -69,8 +68,6 @@ public class FullyQualifiedReflectivePathTerminal<E>
|
||||||
private Function<SemanticQueryWalker<?>, ?> resolveTerminalSemantic() {
|
private Function<SemanticQueryWalker<?>, ?> resolveTerminalSemantic() {
|
||||||
return semanticQueryWalker -> {
|
return semanticQueryWalker -> {
|
||||||
final SqmCreationContext creationContext = creationState.getCreationContext();
|
final SqmCreationContext creationContext = creationState.getCreationContext();
|
||||||
final ClassLoaderService cls =
|
|
||||||
creationContext.getServiceRegistry().requireService( ClassLoaderService.class );
|
|
||||||
final String fullPath = getFullPath();
|
final String fullPath = getFullPath();
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -85,7 +82,7 @@ public class FullyQualifiedReflectivePathTerminal<E>
|
||||||
// See if it is a Class FQN
|
// See if it is a Class FQN
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Class<?> namedClass = cls.classForName( fullPath );
|
final Class<?> namedClass = creationContext.classForName( fullPath );
|
||||||
if ( namedClass != null ) {
|
if ( namedClass != null ) {
|
||||||
return semanticQueryWalker.visitFullyQualifiedClass( namedClass );
|
return semanticQueryWalker.visitFullyQualifiedClass( namedClass );
|
||||||
}
|
}
|
||||||
|
@ -99,7 +96,7 @@ public class FullyQualifiedReflectivePathTerminal<E>
|
||||||
|
|
||||||
final String parentFullPath = getParent().getFullPath();
|
final String parentFullPath = getParent().getFullPath();
|
||||||
try {
|
try {
|
||||||
final Class<?> namedClass = cls.classForName( parentFullPath );
|
final Class<?> namedClass = creationContext.classForName( parentFullPath );
|
||||||
if ( namedClass != null ) {
|
if ( namedClass != null ) {
|
||||||
return createEnumOrFieldLiteral( namedClass );
|
return createEnumOrFieldLiteral( namedClass );
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,6 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
import org.hibernate.dialect.function.SqlColumn;
|
import org.hibernate.dialect.function.SqlColumn;
|
||||||
import org.hibernate.grammars.hql.HqlLexer;
|
import org.hibernate.grammars.hql.HqlLexer;
|
||||||
|
@ -1553,17 +1552,12 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
private JavaType<?> resolveInstantiationTargetJtd(String className) {
|
private JavaType<?> resolveInstantiationTargetJtd(String className) {
|
||||||
final Class<?> targetJavaType = classForName( creationContext.getJpaMetamodel().qualifyImportableName( className ) );
|
final String qualifiedName = creationContext.getJpaMetamodel().qualifyImportableName( className );
|
||||||
return creationContext.getJpaMetamodel()
|
final Class<?> targetJavaType = creationContext.classForName( qualifiedName );
|
||||||
.getTypeConfiguration()
|
return creationContext.getTypeConfiguration().getJavaTypeRegistry()
|
||||||
.getJavaTypeRegistry()
|
|
||||||
.resolveDescriptor( targetJavaType );
|
.resolveDescriptor( targetJavaType );
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<?> classForName(String className) {
|
|
||||||
return creationContext.getServiceRegistry().requireService( ClassLoaderService.class ).classForName( className );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmDynamicInstantiationArgument<?> visitInstantiationArgument(HqlParser.InstantiationArgumentContext ctx) {
|
public SqmDynamicInstantiationArgument<?> visitInstantiationArgument(HqlParser.InstantiationArgumentContext ctx) {
|
||||||
final HqlParser.VariableContext variable = ctx.variable();
|
final HqlParser.VariableContext variable = ctx.variable();
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.hibernate.Incubating;
|
||||||
import org.hibernate.query.BindingContext;
|
import org.hibernate.query.BindingContext;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.sqm.NodeBuilder;
|
import org.hibernate.query.sqm.NodeBuilder;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The context in which all SQM creations occur.
|
* The context in which all SQM creations occur.
|
||||||
|
@ -25,7 +24,10 @@ public interface SqmCreationContext extends BindingContext {
|
||||||
return getQueryEngine().getCriteriaBuilder();
|
return getQueryEngine().getCriteriaBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
default ServiceRegistry getServiceRegistry() {
|
/**
|
||||||
return getJpaMetamodel().getServiceRegistry();
|
* @apiNote Avoid calling this method, since {@link Class}
|
||||||
}
|
* objects are not available to the query validator
|
||||||
|
* in Hibernate Processor at compilation time.
|
||||||
|
*/
|
||||||
|
Class<?> classForName(String className);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.sql.ast.spi;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||||
import org.hibernate.query.BindingContext;
|
import org.hibernate.query.BindingContext;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "context" in which creation of SQL AST occurs. Provides
|
* The "context" in which creation of SQL AST occurs. Provides
|
||||||
|
@ -28,11 +27,6 @@ public interface SqlAstCreationContext extends BindingContext {
|
||||||
*/
|
*/
|
||||||
MappingMetamodelImplementor getMappingMetamodel();
|
MappingMetamodelImplementor getMappingMetamodel();
|
||||||
|
|
||||||
/**
|
|
||||||
* Access to Services
|
|
||||||
*/
|
|
||||||
ServiceRegistry getServiceRegistry();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When creating {@link org.hibernate.sql.results.graph.Fetch} references,
|
* When creating {@link org.hibernate.sql.results.graph.Fetch} references,
|
||||||
* defines a limit to how deep we should join for fetches.
|
* defines a limit to how deep we should join for fetches.
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
import org.hibernate.metamodel.model.domain.JpaMetamodel;
|
||||||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
import org.hibernate.query.sqm.tree.select.SqmSelectStatement;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
|
||||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||||
import org.hibernate.sql.exec.spi.Callback;
|
import org.hibernate.sql.exec.spi.Callback;
|
||||||
|
|
||||||
|
@ -92,11 +91,6 @@ public abstract class BaseSqmUnitTest
|
||||||
return sessionFactory().getJpaMetamodel();
|
return sessionFactory().getJpaMetamodel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ServiceRegistry getServiceRegistry() {
|
|
||||||
return sessionFactory().getServiceRegistry();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getMaximumFetchDepth() {
|
public Integer getMaximumFetchDepth() {
|
||||||
return sessionFactory().getMaximumFetchDepth();
|
return sessionFactory().getMaximumFetchDepth();
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.hibernate.boot.model.relational.Database;
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||||
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
import org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl;
|
||||||
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||||
import org.hibernate.boot.spi.BootstrapContext;
|
import org.hibernate.boot.spi.BootstrapContext;
|
||||||
|
@ -364,6 +365,12 @@ public abstract class MockSessionFactory
|
||||||
return serviceRegistry;
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> classForName(String className) {
|
||||||
|
return serviceRegistry.requireService( ClassLoaderService.class )
|
||||||
|
.classForName( className );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JdbcServices getJdbcServices() {
|
public JdbcServices getJdbcServices() {
|
||||||
return MockJdbcServicesInitiator.jdbcServices;
|
return MockJdbcServicesInitiator.jdbcServices;
|
||||||
|
|
Loading…
Reference in New Issue