persistence@glassfish.java.net

Re: JPQL: add query name and text to query error messages (issue 1795)

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Wed, 20 Dec 2006 14:47:23 +0100

Hi Tom, hi Jielin,

attached you find an updated version of my changes to fix 1795
"Usability improvment: Log details about a NamedQuery when its
compilation fails". I merged my updates with Jielin's recent changes
adding line and column information to the query error messages. The
interesting changes are in EJBQLException/EJBQLExceptionResource and in
the EJBQLParser. A lot of parse tree node need to be changed just
because of the updated signature of the method creating the exception.

Thanks!

Regards Michael

> Hi Tom, hi Jielin,
>
> attached you find my changes to fix the enhancement issue 1795
> "Usability improvment: Log details about a NamedQuery when its
> compilation fails":
> https://glassfish.dev.java.net/issues/show_bug.cgi?id=1795.
>
> This fix include two parts:
> - Add a new overloaded method to create a query parser instance to the
> internal parser API. The new method takes a the name of a named query
> in addition to the query text. This allows the parser to add the name
> to an error message. I added the name (if available) as a prefix to
> the query text included in the beginning of the error message, e.g.
> "Syntax error parsing the query [findCustomersByCity: SELECT c FROM
> Customer c c WHERE c.city = :city], unexpected token [c]."
> - In the current implementation only syntax errors include the query
> text in the error message. I added the query text to the other error
> messages, e.g.
> "Error compiling the query [{0}]. Multiple declaration of
> identification variable [{1}], previously declared as [{2} {1}]."
>
> Jielin,
> you are currently working on 1355 "Add line and column info to query
> compiler error messages" which affects the same sources. I will wait
> until you checked in and then merge my changes.
>
> Thanks!
>
> Regards Michael