From 0c48c12f99759b465b64016e806c7e020940b5bf 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 | 5 +++++ 1 file changed, 5 insertions(+) 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 f070139b0f..6249b66859 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 @@ -45,6 +45,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.JpaMetamodel; @@ -721,6 +722,10 @@ public class MappingMetamodelImpl extends QueryParameterBindingTypeResolverImpl SqmExpressible sqmExpressible, Function tableGroupLocator) { if ( sqmExpressible instanceof SqmPath sqmPath ) { + final DomainType sqmPathType = sqmPath.getResolvedModel().getSqmPathType(); + if ( sqmPathType instanceof MappingModelExpressible mappingExpressible ) { + return mappingExpressible; + } final NavigablePath navigablePath = sqmPath.getNavigablePath(); if ( navigablePath.getParent() != null ) { final TableGroup parentTableGroup = tableGroupLocator.apply( navigablePath.getParent() );