From e9d3ce0defe0fdfc8d1eb84b6ea93a089f195af0 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Mon, 1 Jul 2024 10:13:13 +0200 Subject: [PATCH] HHH-18321 Avoid search for table group when possible for paths --- .../model/domain/internal/MappingMetamodelImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java index e5c101f5f2..05f3d784ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappingMetamodelImpl.java @@ -47,6 +47,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.MappingModelExpressible; import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess; import org.hibernate.metamodel.model.domain.BasicDomainType; +import org.hibernate.metamodel.model.domain.DomainType; import org.hibernate.metamodel.model.domain.EmbeddableDomainType; import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.metamodel.model.domain.ManagedDomainType; @@ -791,8 +792,12 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl public MappingModelExpressible resolveMappingExpressible( SqmExpressible sqmExpressible, Function tableGroupLocator) { - if ( sqmExpressible instanceof SqmPath ) { + if ( sqmExpressible instanceof SqmPath ) { final SqmPath sqmPath = (SqmPath) sqmExpressible; + final DomainType sqmPathType = sqmPath.getResolvedModel().getSqmPathType(); + if ( sqmPathType instanceof MappingModelExpressible ) { + return (MappingModelExpressible) sqmPathType; + } final NavigablePath navigablePath = sqmPath.getNavigablePath(); if ( navigablePath.getParent() != null ) { final TableGroup parentTableGroup = tableGroupLocator.apply( navigablePath.getParent() );