diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index ea93a1e941..b2d587970e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -5214,7 +5214,7 @@ public abstract class BaseSqmToSqlAstConverter 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 subclassEntityNames = entityDescriptor.getSubclassEntityNames(); return createTreatTypeRestriction( lhs, subclassEntityNames ); }