| With an entity hierarchy as souch: A B extends A C1 extendes B C2 extends B D extends C1 creating a query using treat:
select A from A where treat(b as B).property = 'something';
the generated sql will be:
select ...
from A
where DTYPE in ('C2') and ...
C1 and B are missing, but should be there, since they are not Abstract. The culprit is this line of code: https://github.com/hibernate/hibernate-orm/blob/6acfd17548ac1ccfd9af6404965a8719c94d705c/hibernate-core/src/main/java/org/hibernate/persister/entity/SingleTableEntityPersister.java#L635
if ( !actualQueryable.hasSubclasses() ) {
values.add( actualQueryable.getDiscriminatorSQLValue() );
}
the subclass should be excluded from the query only if the entity is Abstract |