persistence@glassfish.java.net

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

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Tue, 19 Dec 2006 17:58:59 +0100

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