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 1ddf519b76
commit b4dabaeadd
1 changed files with 1 additions and 1 deletions

View File

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