persistence@glassfish.java.net

Use of parameters in IN statement

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Fri, 30 Oct 2009 16:26:27 -0400

Dear colleagues,

Does EJBQL grammar support named/positional in the IN statement?

According to 4.6.4 Input Parameters of spec:

"Input parameters can only be used in the WHERE clause or HAVING clause
of a query."

Since an IN expression is within a WHERE clause I assumed I could use
parameter within the IN statement.

However, when I use the :type parameter in query below I get no errors
and no matches (I was expecting a match):

SELECT DISTINCT Object(p) FROM PersonType p, AssociationType a WHERE
    (a.sourceObject = 'urn:wellfleetsoftware:Association:farrukhNajmi' AND
     p.id = a.targetObject AND
     a.type IN ( :type ))

When I replace :type in above with the parameter value in the query
(hard code it) then all works as expected and I get some matches.

Is this expected? If so where is it defined in the spec? Thanks.

-- 
Regards,
Farrukh
Web: http://www.wellfleetsoftware.com