Ok so essentially what you are saying with what you expect for 1 and 2 is that the treat operator shouldn't cause filtering of subtypes If you remove the subtype filtering testcase 1 and 2 should be ok except for single table inheritance column sharing cases which is a separate issue. I think testcase 3 is invalid in the sense that you'd expect treat to filter the subtypes. What you probably wanted to express is
select e from BaseType as e where (type(e) = SubType1 and e.basevalue = 100) or treat(e as SubType2).subvalue2 = 200
I blame JPA spec 4.4.9 for being ambiguous about when subtype filtering should be applied. I hope you agree that applying subtype filtering for treats that appear in any other clause than FROM doesn't feel right. If so, then this issue should be resolved and two additional issues have to be added
- Treat in non FROM clauses shouldn't cause subtype filtering
- Access to shared columns on treated join aliases for single table inheritance must result in case when type(..) .. then column end
|