persistence@glassfish.java.net

Issue 2084: Generated SQL uses wrong alias for orderby clause

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Thu, 25 Jan 2007 15:30:59 +0100

Hi Tom,

some news about issue 2084 "Generated SQL uses wrong alias for orderby
clause" (https://glassfish.dev.java.net/issues/show_bug.cgi?id=2084).
Meanwhile there is a forum posting describing the same problem:
http://forums.java.net/jive/thread.jspa?threadID=22164&tstart=0

I figured out the issue only occurs if the named query is mapped to a
ReadAllQuery instance, so the generated SQL is correct when using a
ReportQuery. This means my change for 1519 "JPQL: create a ReadAllQuery
for simple queries" exposed this problem.

I propose I disable the code in the query compiler creating a
ReadAllQuery for simple queries. So for the time being the query
compiler would always generate a ReportQuery instance for a JPQL SELECT
query. Please note, this change allows to run the named query as
described in issue 2084, but it does not fix the runtime issue of the
invalid SQL for a ReadAllQuery. So I would like to keep 2084 open, but
maybe it is ok to downgrade it to a P3.

What do you think?

Regards Michael