persistence@glassfish.java.net

RE: EJBQL join handling fixes

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Wed, 8 Mar 2006 11:53:41 -0500

Hello Michael,
        The changes look great.
Thanks,
Gordon

-----Original Message-----
From: Michael Bouschen [mailto:Michael.Bouschen_at_Sun.COM]
Sent: Wednesday, March 08, 2006 11:19 AM
To: Gordon Yorke
Cc: persistence_at_glassfish.dev.java.net
Subject: EJBQL join handling fixes


Hi Gordon,

attached (EJBQL-join-060308.jar) you find my EJB QL compiler changes
fixing two issues about joins in EJB QL:
(1) https://glassfish.dev.java.net/issues/show_bug.cgi?id=186
This is about an identification variable that is defined in a JOIN
clause but not used in the rest of the query, e.g. the variable c in
   SELECT o FROM Order o JOIN o.customer c
The ParseTreeContext manages a set of used variables. The parse tree
calls reportQuery.addNonFetchJoinedAttribute for all variables that are
not used in the WHERE or SELECT clause. This makes sure the generated
SQL includes a foreign key join clause for o.customer.

(2) https://glassfish.dev.java.net/issues/show_bug.cgi?id=187
This is about JOIN FETCH in EJB QL, e.g.
   SELECT c from Customer c JOIN FETCH c.spouse
The ParseTreeContext manages a map with the identification variable name
as key and a list of fetch join clauses as values. When processing the
SELECT clause of the query the code now calls
   reportQuery.addItem(variable, expression, fetchJoinExprs)
in case an identification variable is selected.

The other jar EJBQL-joinTests-060308.jar add two test cases to the
JUnitEJBQLComplexTestSuite test class.

Thanks!

Regards Michael