persistence@glassfish.java.net

Re: EJBQL: fix for problem with IN-expr including input parameter

From: Shelly (Donna) McGowan <"Shelly>
Date: Fri, 13 Jan 2006 09:46:09 -0500

Michael,

You had requested information regarding IN expression at yesterday's
meeting. Was it related to IN expression with a parameter or subquery or
something else? My note from the meeting states: "other failures with
IN clause?"

I leave the implementation assessment to you here but wanted to note
that I am seeing the subquery_join clause fail with where the stack
trace comes from invalidQueryKeyInExpression also.

  "SELECT c FROM Customer c JOIN c.orders o WHERE EXISTS "
                + "(SELECT o FROM o.lineItems l where l.quantity > 3 ) ")
Local Exception Stack:
Exception [TOPLINK-6015] (Oracle TopLink Essentials - 10g release 4
(10.1.4.0.0) (Build 060104Dev)): oracle.toplink.essential
s.exceptions.QueryException
Exception Description: Invalid query key [orders] in expression.
Query:
ReportQuery(com.sun.ts.tests.ejb30.persistence.query.language.schema30.Customer)
        at
oracle.toplink.essentials.exceptions.QueryException.invalidQueryKeyInExpression(QueryException.java:606)
        at
oracle.toplink.essentials.internal.expressions.QueryKeyExpression.validateNode(QueryKeyExpression.java:685)
        at
oracle.toplink.essentials.expressions.Expression.normalize(Expression.java:2475)
        at
oracle.toplink.essentials.internal.expressions.DataExpression.normalize(DataExpression.java:343)
        at
oracle.toplink.essentials.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:464)
        at
oracle.toplink.essentials.internal.expressions.QueryKeyExpression.normalize(QueryKeyExpression.java:451)
        at
oracle.toplink.essentials.internal.expressions.RelationExpression.normalize(RelationExpression.java:469)
        at
oracle.toplink.essentials.internal.expressions.CompoundExpression.normalize(CompoundExpression.java:164)
        at
oracle.toplink.essentials.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1174)
        at
oracle.toplink.essentials.internal.expressions.SubSelectExpression.normalizeSubSelect(SubSelectExpression.java:143
)
        at
oracle.toplink.essentials.internal.expressions.ExpressionNormalizer.normalizeSubSelects(ExpressionNormalizer.java:
102)
        at
oracle.toplink.essentials.internal.expressions.SQLSelectStatement.normalize(SQLSelectStatement.java:1247)
        at
oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.buildReportQuerySelectStatement(Express
ionQueryMechanism.java:433)
        at
oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.buildReportQuerySelectStatement(Express
ionQueryMechanism.java:403)
        at
oracle.toplink.essentials.internal.queryframework.ExpressionQueryMechanism.prepareReportQuerySelectAllRows(Express
ionQueryMechanism.java:1225)
        at
oracle.toplink.essentials.queryframework.ReportQuery.prepareSelectAllRows(ReportQuery.java:878)
        at
oracle.toplink.essentials.queryframework.ReadAllQuery.prepare(ReadAllQuery.java:398)

Michael Bouschen wrote On 01/13/06 09:26,:
> Hi Tom,
>
> I think I have a fix for the EJBQL problem with an IN-expression
> including an input parameter:
> SELECT c From Customer c where c.home.city IN(:city)
>
> The fix changes the parse tree node InNode and removes the special
> handling of input parameter. Now the InNode passes an array of
> Expression instances to the backend instead of a Vector of constant
> values. I added two methods to the Expression class: in and notIn both
> taking an array of Expression instances.
>
> Thanks!
>
> Regards Michael