[
https://issues.apache.org/jira/browse/CAY-1935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14016898#comment-14016898
]
Andrus Adamchik commented on CAY-1935:
--------------------------------------
I agree with the idea, and the patch looks good. So +1.
As a side note, at this point we don't care so much about compatibility with
JPA spec, but rather about eventual unification and merging of EJBQL and
Expression. Proposed change is in line with this goal, and seems to match the
Expression grammar:
http://cayenne.apache.org/docs/3.1/cayenne-guide/expressions-bnf.html
"in" ( namedParameter | "(" scalarCommaList ")" )
> EJBQL; Handling Collection as Parameter in IN Expression
> --------------------------------------------------------
>
> Key: CAY-1935
> URL: https://issues.apache.org/jira/browse/CAY-1935
> Project: Cayenne
> Issue Type: Improvement
> Affects Versions: 3.2M1
> Reporter: Andrew Lindesay
> Attachments: CAY-1935-17may2014_in.patch
>
>
> Consider an EJBQL expression fragment...
> {noformat}
> ... p.toArtist IN (:artists)
> {noformat}
> ...where :artists may be bound to a Collection such as List or Set. Cayenne
> presently takes the named or positional parameter bound to the collection to
> be a _member_ of the set of elements to which the lvar should be a member
> rather than the set itself. Obviously this doesn't process correctly.
> This patch will mean that in this situation above, the parameter bound to the
> Collection is _expanded_ to actually be the set of elements to which the LVAR
> should be a member.
> There is some discussion of this
> [here|http://glassfish.10926.n7.nabble.com/Use-of-parameters-in-IN-statement-td87353.html]
> and
> [here|http://stackoverflow.com/questions/2772305/jpql-in-clause-java-arrays-or-lists-sets].
> Because some query systems support an unbracketed collection-parameter for
> IN, "EJBQLParser.jjt" has been modified in this patch to allow for either
> approach; hence a query of the following form would also be supported;
> {noformat}
> ... p.toArtist IN :artists
> {noformat}
> Note that this new functionality only applies if there is a _single_
> unbracketed parameter or if there is a _single_ bracketed parameter - it does
> not take effect if there are multiple parameters in play. If there is a
> single unbracketed parameter that is not a collection then it will function
> as if that parameter were bracketed.
--
This message was sent by Atlassian JIRA
(v6.2#6252)