From b4e26b3e3270a62113ea1c9d1d031e802cd8042a Mon Sep 17 00:00:00 2001 From: Gavin King Date: Tue, 10 Sep 2024 11:30:10 +0200 Subject: [PATCH] refactor a bit the BindingContext hierarchy --- .../spi/SessionFactoryDelegatingImpl.java | 4 ++-- .../engine/spi/SessionFactoryImplementor.java | 4 ---- .../internal/parse/PathQualifierType.java | 7 +++--- .../internal/AbstractPluralAttribute.java | 4 ++-- .../domain/internal/DomainModelHelper.java | 6 +++-- .../domain/internal/EntitySqmPathSource.java | 4 ++-- .../model/domain/internal/EntityTypeImpl.java | 4 ++-- .../domain/internal/ListAttributeImpl.java | 4 ++-- .../domain/internal/MapAttributeImpl.java | 4 ++-- .../internal/SingularAttributeImpl.java | 4 ++-- .../org/hibernate/query/BindingContext.java | 6 ++++- .../internal/BasicDotIdentifierConsumer.java | 8 +++---- .../hql/internal/SemanticQueryBuilder.java | 4 ++-- .../hql/internal/SqmPathRegistryImpl.java | 4 ++-- .../hibernate/query/sqm/SqmPathSource.java | 6 ++--- .../query/sqm/spi/SqmCreationContext.java | 24 ++++--------------- .../validation/MockSessionFactory.java | 3 ++- 17 files changed, 44 insertions(+), 56 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryDelegatingImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryDelegatingImpl.java index 40cd05191d..f819e57603 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryDelegatingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryDelegatingImpl.java @@ -40,7 +40,7 @@ import org.hibernate.engine.profile.FetchProfile; import org.hibernate.event.spi.EventEngine; import org.hibernate.graph.spi.RootGraphImplementor; import org.hibernate.internal.FastSessionServices; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.spi.MetamodelImplementor; import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor; import org.hibernate.proxy.EntityNotFoundDelegate; @@ -265,7 +265,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor, } @Override - public JpaMetamodelImplementor getJpaMetamodel() { + public JpaMetamodel getJpaMetamodel() { return delegate.getJpaMetamodel(); } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java index 2add13d113..8adb4fdcc1 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionFactoryImplementor.java @@ -25,7 +25,6 @@ import org.hibernate.metamodel.spi.MappingMetamodelImplementor; import org.hibernate.metamodel.spi.MetamodelImplementor; import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor; import org.hibernate.proxy.EntityNotFoundDelegate; -import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.spi.QueryParameterBindingTypeResolver; import org.hibernate.query.sqm.spi.SqmCreationContext; import org.hibernate.service.spi.ServiceRegistryImplementor; @@ -91,9 +90,6 @@ public interface SessionFactoryImplementor return getRuntimeMetamodels().getMappingMetamodel(); } - @Override - QueryEngine getQueryEngine(); - @Override SessionBuilderImplementor withOptions(); diff --git a/hibernate-core/src/main/java/org/hibernate/graph/internal/parse/PathQualifierType.java b/hibernate-core/src/main/java/org/hibernate/graph/internal/parse/PathQualifierType.java index e7f34d5e8c..a7bdc1f946 100644 --- a/hibernate-core/src/main/java/org/hibernate/graph/internal/parse/PathQualifierType.java +++ b/hibernate-core/src/main/java/org/hibernate/graph/internal/parse/PathQualifierType.java @@ -8,6 +8,7 @@ package org.hibernate.graph.internal.parse; import org.hibernate.graph.CannotContainSubGraphException; import org.hibernate.metamodel.model.domain.DomainType; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.ManagedDomainType; import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; @@ -42,13 +43,11 @@ public enum PathQualifierType { private static ManagedDomainType resolveSubTypeManagedType( DomainType graphType, String subTypeName, - JpaMetamodelImplementor metamodel) { - if ( !( graphType instanceof ManagedDomainType ) ) { + JpaMetamodel metamodel) { + if ( !( graphType instanceof ManagedDomainType managedType ) ) { throw new CannotContainSubGraphException( "The given type [" + graphType + "] is not a ManagedType" ); } - ManagedDomainType managedType = (ManagedDomainType) graphType; - if ( subTypeName != null ) { managedType = resolveSubType( managedType, subTypeName, metamodel ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/AbstractPluralAttribute.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/AbstractPluralAttribute.java index 116230ccf1..65048fc120 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/AbstractPluralAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/AbstractPluralAttribute.java @@ -14,9 +14,9 @@ import org.hibernate.metamodel.internal.MetadataContext; import org.hibernate.metamodel.mapping.CollectionPart; import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.PluralPersistentAttribute; import org.hibernate.metamodel.model.domain.SimpleDomainType; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.spi.NavigablePath; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.internal.SqmMappingModelHelper; @@ -89,7 +89,7 @@ public abstract class AbstractPluralAttribute } @Override - public SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { if ( CollectionPart.Nature.ELEMENT.getName().equals( name ) ) { return elementPathSource; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DomainModelHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DomainModelHelper.java index f44045b797..ac3ad3a5ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DomainModelHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/DomainModelHelper.java @@ -59,11 +59,13 @@ public class DomainModelHelper { static boolean isCompatible( PersistentAttribute attribute1, PersistentAttribute attribute2, - JpaMetamodelImplementor jpaMetamodel) { + JpaMetamodel jpaMetamodel) { if ( attribute1 == attribute2 ) { return true; } - final MappingMetamodel runtimeMetamodels = jpaMetamodel.getMappingMetamodel(); + final MappingMetamodel runtimeMetamodels = + //TODO: eliminate this cast! + ((JpaMetamodelImplementor) jpaMetamodel).getMappingMetamodel(); final ModelPart modelPart1 = getEntityAttributeModelPart( attribute1, attribute1.getDeclaringType(), diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntitySqmPathSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntitySqmPathSource.java index 40847f34a6..93bf55ab65 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntitySqmPathSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntitySqmPathSource.java @@ -7,7 +7,7 @@ package org.hibernate.metamodel.model.domain.internal; import org.hibernate.metamodel.model.domain.EntityDomainType; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.query.hql.spi.SqmCreationState; import org.hibernate.query.sqm.SqmJoinable; import org.hibernate.query.sqm.SqmPathSource; @@ -44,7 +44,7 @@ public class EntitySqmPathSource extends AbstractSqmPathSource implements } @Override - public SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { return getSqmPathType().findSubPathSource( name, metamodel ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java index 462ceb3d29..891a085378 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java @@ -160,7 +160,7 @@ public class EntityTypeImpl } @Override - public SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { final PersistentAttribute attribute = super.findAttribute( name ); if ( attribute != null ) { return (SqmPathSource) attribute; @@ -182,7 +182,7 @@ public class EntityTypeImpl return null; } - private PersistentAttribute findSubtypeAttribute(String name, JpaMetamodelImplementor metamodel) { + private PersistentAttribute findSubtypeAttribute(String name, JpaMetamodel metamodel) { PersistentAttribute subtypeAttribute = null; for ( ManagedDomainType subtype : getSubTypes() ) { final PersistentAttribute candidate = subtype.findSubTypesAttribute( name ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/ListAttributeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/ListAttributeImpl.java index 13989dce9b..ca922c5877 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/ListAttributeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/ListAttributeImpl.java @@ -10,8 +10,8 @@ import java.util.List; import org.hibernate.metamodel.internal.MetadataContext; import org.hibernate.metamodel.mapping.CollectionPart; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.ListPersistentAttribute; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.hql.spi.SqmCreationState; import org.hibernate.query.sqm.internal.SqmMappingModelHelper; @@ -62,7 +62,7 @@ public class ListAttributeImpl extends AbstractPluralAttribute, } @Override - public SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { final CollectionPart.Nature nature = CollectionPart.Nature.fromNameExact( name ); if ( nature != null ) { switch ( nature ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java index 9d81e106a2..c55b628cec 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MapAttributeImpl.java @@ -10,9 +10,9 @@ import java.util.Map; import org.hibernate.metamodel.internal.MetadataContext; import org.hibernate.metamodel.mapping.CollectionPart; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.MapPersistentAttribute; import org.hibernate.metamodel.model.domain.SimpleDomainType; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.hql.spi.SqmCreationState; import org.hibernate.query.sqm.internal.SqmMappingModelHelper; @@ -72,7 +72,7 @@ public class MapAttributeImpl extends AbstractPluralAttribute findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { final CollectionPart.Nature nature = CollectionPart.Nature.fromNameExact( name ); if ( nature != null ) { switch ( nature ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/SingularAttributeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/SingularAttributeImpl.java index 23569230db..9f64116026 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/SingularAttributeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/SingularAttributeImpl.java @@ -16,11 +16,11 @@ import org.hibernate.metamodel.model.domain.AnyMappingDomainType; import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.metamodel.model.domain.IdentifiableDomainType; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.ManagedDomainType; import org.hibernate.metamodel.model.domain.PluralPersistentAttribute; import org.hibernate.metamodel.model.domain.SimpleDomainType; import org.hibernate.metamodel.model.domain.SingularPersistentAttribute; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.query.SemanticException; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.hql.spi.SqmCreationState; @@ -130,7 +130,7 @@ public class SingularAttributeImpl } @Override - public SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { return sqmPathSource.findSubPathSource( name, metamodel ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/BindingContext.java b/hibernate-core/src/main/java/org/hibernate/query/BindingContext.java index 56be2540b9..ad1dcff191 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/BindingContext.java +++ b/hibernate-core/src/main/java/org/hibernate/query/BindingContext.java @@ -21,7 +21,11 @@ import org.hibernate.type.spi.TypeConfiguration; */ @Incubating public interface BindingContext { - TypeConfiguration getTypeConfiguration(); JpaMetamodel getJpaMetamodel(); + MappingMetamodel getMappingMetamodel(); + + default TypeConfiguration getTypeConfiguration() { + return getJpaMetamodel().getTypeConfiguration(); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/BasicDotIdentifierConsumer.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/BasicDotIdentifierConsumer.java index daa4ec5e29..a7a3ecbb67 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/BasicDotIdentifierConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/BasicDotIdentifierConsumer.java @@ -8,8 +8,8 @@ package org.hibernate.query.hql.internal; import org.hibernate.metamodel.model.domain.EmbeddableDomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.ManagedDomainType; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.query.SemanticException; import org.hibernate.query.hql.HqlLogging; import org.hibernate.query.hql.spi.DotIdentifierConsumer; @@ -183,7 +183,7 @@ public class BasicDotIdentifierConsumer implements DotIdentifierConsumer { } final String path = pathSoFar.toString(); - final JpaMetamodelImplementor jpaMetamodel = creationContext.getJpaMetamodel(); + final JpaMetamodel jpaMetamodel = creationContext.getJpaMetamodel(); final String importableName = jpaMetamodel.qualifyImportableName( path ); final NodeBuilder nodeBuilder = creationContext.getNodeBuilder(); if ( importableName != null ) { @@ -232,7 +232,7 @@ public class BasicDotIdentifierConsumer implements DotIdentifierConsumer { } private static SqmFieldLiteral sqmFieldLiteral( - JpaMetamodelImplementor jpaMetamodel, + JpaMetamodel jpaMetamodel, String prefix, String terminal, JavaType fieldJtdTest, @@ -246,7 +246,7 @@ public class BasicDotIdentifierConsumer implements DotIdentifierConsumer { } private static > SqmEnumLiteral sqmEnumLiteral( - JpaMetamodelImplementor jpaMetamodel, + JpaMetamodel jpaMetamodel, EnumJavaType enumType, String terminal, NodeBuilder nodeBuilder) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java index 253a38fd83..c60e3d3cbd 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SemanticQueryBuilder.java @@ -48,13 +48,13 @@ import org.hibernate.metamodel.model.domain.BasicDomainType; import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.metamodel.model.domain.IdentifiableDomainType; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.ManagedDomainType; import org.hibernate.metamodel.model.domain.PersistentAttribute; import org.hibernate.metamodel.model.domain.PluralPersistentAttribute; import org.hibernate.metamodel.model.domain.SingularPersistentAttribute; import org.hibernate.metamodel.model.domain.internal.AnyDiscriminatorSqmPath; import org.hibernate.metamodel.model.domain.internal.EntitySqmPathSource; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.query.NullPrecedence; import org.hibernate.query.ParameterLabelException; import org.hibernate.query.PathException; @@ -1287,7 +1287,7 @@ public class SemanticQueryBuilder extends HqlParserBaseVisitor implem } private EntityDomainType getResultEntity() { - final JpaMetamodelImplementor jpaMetamodel = creationContext.getJpaMetamodel(); + final JpaMetamodel jpaMetamodel = creationContext.getJpaMetamodel(); if ( expectedResultEntity != null ) { @SuppressWarnings("rawtypes") final EntityDomainType entityDescriptor = jpaMetamodel.entity( expectedResultEntity ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SqmPathRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SqmPathRegistryImpl.java index 2838d1d602..c57d188eb0 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SqmPathRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/SqmPathRegistryImpl.java @@ -15,7 +15,7 @@ import java.util.function.Function; import org.hibernate.jpa.spi.JpaCompliance; import org.hibernate.metamodel.model.domain.BasicDomainType; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.query.criteria.JpaCrossJoin; import org.hibernate.query.SemanticException; import org.hibernate.query.hql.HqlLogging; @@ -331,7 +331,7 @@ public class SqmPathRegistryImpl implements SqmPathRegistry { && containerType.findSubPathSource( name, getJpaMetamodel() ) != null; } - private JpaMetamodelImplementor getJpaMetamodel() { + private JpaMetamodel getJpaMetamodel() { return associatedProcessingState.getCreationState().getCreationContext().getJpaMetamodel(); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/SqmPathSource.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/SqmPathSource.java index 05d3f52e32..1155915e92 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/SqmPathSource.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/SqmPathSource.java @@ -11,7 +11,7 @@ import java.util.Locale; import jakarta.persistence.metamodel.Bindable; import org.hibernate.metamodel.model.domain.DomainType; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.spi.NavigablePath; import org.hibernate.query.sqm.tree.SqmExpressibleAccessor; import org.hibernate.query.sqm.tree.domain.SqmPath; @@ -57,7 +57,7 @@ public interface SqmPathSource extends SqmExpressible, Bindable, SqmExp * * @throws IllegalStateException to indicate that this source cannot be de-referenced */ - default SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + default SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { return findSubPathSource( name ); } @@ -88,7 +88,7 @@ public interface SqmPathSource extends SqmExpressible, Bindable, SqmExp * @throws IllegalStateException to indicate that this source cannot be de-referenced * @throws IllegalArgumentException if the subPathSource is not found */ - default SqmPathSource getSubPathSource(String name, JpaMetamodelImplementor metamodel) { + default SqmPathSource getSubPathSource(String name, JpaMetamodel metamodel) { final SqmPathSource subPathSource = findSubPathSource( name, metamodel ); if ( subPathSource == null ) { throw new PathElementException( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/SqmCreationContext.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/SqmCreationContext.java index b4381eae49..ec67e5a236 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/SqmCreationContext.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/SqmCreationContext.java @@ -7,39 +7,25 @@ package org.hibernate.query.sqm.spi; import org.hibernate.Incubating; -import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor; import org.hibernate.query.BindingContext; import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.service.ServiceRegistry; -import org.hibernate.type.spi.TypeConfiguration; /** - * The context in which all SQM creations occur (think SessionFactory). + * The context in which all SQM creations occur. * * @author Steve Ebersole */ @Incubating public interface SqmCreationContext extends BindingContext { - /** - * Access to the domain model metadata - */ - JpaMetamodelImplementor getJpaMetamodel(); - - /** - * Access to the ServiceRegistry for the context - */ - default ServiceRegistry getServiceRegistry() { - return getJpaMetamodel().getServiceRegistry(); - } - - default TypeConfiguration getTypeConfiguration() { - return getJpaMetamodel().getTypeConfiguration(); - } - QueryEngine getQueryEngine(); default NodeBuilder getNodeBuilder() { return getQueryEngine().getCriteriaBuilder(); } + + default ServiceRegistry getServiceRegistry() { + return getJpaMetamodel().getServiceRegistry(); + } } diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/validation/MockSessionFactory.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/validation/MockSessionFactory.java index dffba25187..76fb36d99c 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/validation/MockSessionFactory.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/validation/MockSessionFactory.java @@ -58,6 +58,7 @@ import org.hibernate.metamodel.internal.RuntimeMetamodelsImpl; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; +import org.hibernate.metamodel.model.domain.JpaMetamodel; import org.hibernate.metamodel.model.domain.ManagedDomainType; import org.hibernate.metamodel.model.domain.PersistentAttribute; import org.hibernate.metamodel.model.domain.internal.AbstractAttribute; @@ -908,7 +909,7 @@ public abstract class MockSessionFactory } @Override - public SqmPathSource findSubPathSource(String name, JpaMetamodelImplementor metamodel) { + public SqmPathSource findSubPathSource(String name, JpaMetamodel metamodel) { SqmPathSource source = super.findSubPathSource(name, metamodel); if ( source != null ) { return source;