HHH-18321 Avoid search for table group when possible for paths

This commit is contained in:
Marco Belladelli 2024-07-01 10:13:13 +02:00
parent 5ca841c184
commit 0c48c12f99
1 changed files with 5 additions and 0 deletions

View File

@ -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<NavigablePath, TableGroup> 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() );