persistence@glassfish.java.net

Re: JPQL: subquery changes

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Tue, 21 Mar 2006 21:18:13 +0100

Hi Tom,

I'm sorry, I include a wrong version of one of the files. Please find a
new jar attached.

Regards Michael

> Hi Michael,
>
> I am getting a compile failure in VariableNode.
>
> originalNode doesn't exist in my code.
>
> public void validate(ParseTreeContext context) {
> if (left != null) {
> // change SELECT clause of subquery
> SubqueryNode subqueryNode = (SubqueryNode)getLeft();
> EJBQLParseTree parseTree = subqueryNode.getParseTree();
> SelectNode selectNode = (SelectNode)parseTree.getQueryNode();
> originalNode = (Node)selectNode.getSelectExpressions().get(0);
> if (originalNode.isVariableNode()) {
>
> -Tom
>
> Michael Bouschen wrote:
>
>> Hi Tom,
>>
>> attached you find new changes fixing two subquery issues:
>> https://glassfish.dev.java.net/issues/show_bug.cgi?id=444
>> https://glassfish.dev.java.net/issues/show_bug.cgi?id=449
>>
>> I changed the validation in the ExistsNode to validate the subquery
>> after I changed the SELECT clause of the subquery to return 1. This
>> causes a joined attributed to be added using
>> addNonFetchJoinedAttribute. This fixes the issue 449. The other
>> change is in SubqueryNode when adding the equal expression connecting
>> variables from the inner and the outer query. I call
>> VariableNode.generateExpression to create the expression instead of
>> just looking it up in the expression cache. There was a case where
>> the cache did not include an expression, so the cache lookup returned
>> null causing the construction of an invalid Expression.
>>
>> Please have a look and please have another test run on your side.
>> Thanks!
>>
>> Regards Michael
>>
>>
>>
>>
>>> Hi Michael,
>>>
>>> These changes look good to me.
>>>
>>> We will definitely have to ensure CTS passes with these changes. Let
>>> me know if you want me to include these changes in our next CTS run.
>>>
>>> -Tom
>>>
>>> Michael Bouschen wrote:
>>>
>>>
>>>
>>>> Hi Tom,
>>>>
>>>> attached are my changes for better subquery support. With these
>>>> changes the SelectGenerationContext created for a subquery does not
>>>> share its expression cache with the one for the outer query.
>>>> Instead it generates an Expression.equal call for all variables
>>>> used in the subquery that are declared in the outer query, e.g. the
>>>> variable c in the following examples:
>>>> SELECT c FROM Customer c WHERE EXISTS (SELECT o FROM c.orders o)
>>>> SELECT c FROM Customer c WHERE EXISTS
>>>> (SELECT o FROM Order o WHERE o.customer.name = c.name)
>>>>
>>>> Please have a look, thanks!
>>>>
>>>> Regards Michael
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>