On Thu, Mar 10, 2011 at 4:56 PM, Michael Bouschen
<michael.bouschen_at_akquinet.de> wrote:
> In "JOIN TREAT(o.product AS Book) b" Product is a superclass of Book, so
> this is a valid downcast (=> no Exception). The only way for an exception
> would be if there is no inheritance relationship between Product and Book.
>
> Regards Michael
>
Ah, the latter example is where I was missing the nuance. Essentially, then:
Case 1:
if (Product.class.isAssignableFrom(Book.class)) {
// consider expression false for those products that are not books
}
Case 2:
if (!Product.class.isAssignableFrom(Book.class)) {
throw new PersistenceException(new ClassCastException(...));
}
Correct?
If so, then I would restate **for the deferred,
not-currently-specified projection use of TREAT AS** that if either
Book is not assignment-compatible with Product or the filter results
in type-incompatible instances with the projection expression, an
exception is thrown.
-matthew