| I agree. Perhaps you can see access to a property in the supertype as a special case of 'Access to shared columns on treated join aliases for single table inheritance'. If rendered as case when type(..) .. then column end, things should work as expected. There are however 2 nasty cases to keep in mind: IS NULL and NOT. For example, take these JPQL queries (with single table inheritance, for simplicity):
select e from BaseType as e where not(treat(e as SubType1).subvalue1 = 100)
select e from BaseType as e where treat(e as SubType1).subvalue1 is null
When rendering these to SQL like this:
SELECT * FROM BaseType WHERE NOT(subvalue1 = 100)
SELECT * FROM BaseType WHERE subvalue1 IS NULL
The first query will never return any rows, because the negation of a NULL comparison is still false. The second query will return all rows not of type SubType1 plus all rows of type SubType1 with subvalue IS NULL. |