persistence@glassfish.java.net

Re: JPQL: validate field access in SELECT clause

From: Tom Ware <tom.ware_at_oracle.com>
Date: Tue, 30 May 2006 09:26:30 -0400

Hi Michael,

  Your changes look good.

-Tom

Michael Bouschen wrote:

>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
>
>
>