persistence@glassfish.java.net

JPQL: validate field access in SELECT clause

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Tue, 30 May 2006 14:16:44 +0200

Hi Tom,

I fixed issue 685 "JPQL validation: missing SELECT clause validation
causes NPE": https://glassfish.dev.java.net/issues/show_bug.cgi?id=685

You find the changes in the attached jar JPQL-fix685-060530.jar. I added
two checks to the validate method in DotNode validating an expression of
the form 'expr.field'. It first checks whether 'expr' has a navigable
type. This throws an exception if 'expr' has a primitive type, a wrapper
class, String, etc. The second check throws an exception if 'field' is
not a state or association field defined by the type of 'expr'.

The other jar JPQL-fix685-tests-060530.jar includes changes in
entity-persistence-tests. I added two new test methods to the EJBQL
validation test class. I also fixed some existing queries accessing
undefined fields. They were part of negative tests, meaning the query is
invalid and the test checks whether the compiler catches the error. With
my change the query compiler finds the invalid field access first and
reports an unexpected error.

Thanks!

Regards Michael