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() );