I personally don't think the JPA spec team has considered the case where you use treat to access a property you already have access to just restrict the type for the same predicate. When the accessed property is from the subtype, the predicate would evaluate to false for instances that aren't of that type because UNKNOWN means FALSE. In the end, the JPA EG must decide what is appropriate, but as far as I undestand, what you want is that e.g. treat(alias as X).property = 1 is the same as type(alias) = X and alias.property = 1 iff property is a declared member of the static type of alias. This doesn't contradict the interpretation I am supporting but can be seen as an extension. Apart from this special case, there is no semantic difference between your and my approach. It's just that my approach generates less SQL as it relies on the fact that UNKNOWN means false. |