Well for the predicates that are not null-aware this is the case implicitly because UNKNOWN results to FALSE. The single table inheritance column sharing case might be problematic, but apart from that I don't see anything that violates the spec. Subtype filtering in this specific case is an allowed optimization but I don't know if it's done because of the right reasons. For your null-aware predicates you can apply your type flitering by introducing another conjunct as I proposed earlier
select generatedAlias0 from BaseType as generatedAlias0 where
( ( type(generatedAlias0) = org.hibernate.bugs.SubType1 )
and ( generatedAlias0.basevalue=100 )
and ( treat(generatedAlias0 as org.hibernate.bugs.SubType1).subvalue1 is null ) ) or
( ( type(generatedAlias0) = org.hibernate.bugs.SubType2 )
and ( generatedAlias0.basevalue=200 )
and ( treat(generatedAlias0 as org.hibernate.bugs.SubType2).subvalue2 is null ) )
This should result in the expected SQL looking about like this
select * from BaseType basetype0_
where
basetype0_.DTYPE in (
'SubType2', 'SubType1'
)
and (
basetype0_.DTYPE = 'SubType1'
and ( basetype0_.basevalue=100 )
and ( basetype0_.subvalue1 is null )
or basetype0_.DTYPE = 'SubType2'
and ( basetype0_.basevalue=200 )
and ( basetype0_.subvalue2 is null )
)
If that isn't what you want/expect could you please rephrase what it is exactly that you think is wrong? |