HHH-17299 Avoid unneeded treats to the same subtype
This commit is contained in:
parent
01c8243876
commit
4087774691
|
@ -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 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue