HHH-17299 Avoid unneeded treats to the same subtype

This commit is contained in:
Marco Belladelli 2023-10-17 12:39:08 +02:00
parent 01c8243876
commit 4087774691
1 changed files with 1 additions and 1 deletions

View File

@ -5212,7 +5212,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
private Predicate createTreatTypeRestriction(SqmPath<?> lhs, EntityDomainType<?> treatTarget) { private Predicate createTreatTypeRestriction(SqmPath<?> lhs, EntityDomainType<?> treatTarget) {
final AbstractEntityPersister entityDescriptor = (AbstractEntityPersister) domainModel.findEntityDescriptor( treatTarget.getHibernateEntityName() ); final AbstractEntityPersister entityDescriptor = (AbstractEntityPersister) domainModel.findEntityDescriptor( treatTarget.getHibernateEntityName() );
if ( entityDescriptor.isPolymorphic() ) { if ( entityDescriptor.isPolymorphic() && lhs.getNodeType() != treatTarget ) {
final Set<String> subclassEntityNames = entityDescriptor.getSubclassEntityNames(); final Set<String> subclassEntityNames = entityDescriptor.getSubclassEntityNames();
return createTreatTypeRestriction( lhs, subclassEntityNames ); return createTreatTypeRestriction( lhs, subclassEntityNames );
} }