Hi Gordon --
I will file an enhancement, but I believe that such an enhancement will
be JPA-provider specific, won't it? I guess it hinges on the
interpretation of the spec when it says "The input parameter values must
be LIKE the same abstract schema type of the state_field_path_expression
type" -- the state field is a string. The individual elements of the
list would be strings, but the type of the input parameter is a list;
I'm not sure which would apply.
So if I'm interesting in writing completely portable code, would this be
expected to work, or would I be expected to iterate my list and do
individual queries?
-Scott
On Mon, 2007-04-16 at 12:58, Gordon Yorke wrote:
> Hello Scott,
> TopLink fully supports provinding a list to a IN function. There may be an issue translating the JPA query parameters to the TopLink parameters. Please file an enhancement request. If you would like you can access the TopLink query directly from the EJBQuery and set the IN parameter list on the TopLink query. If you would like more specifics I would be happy to provide them.
> --Gordon
>
> -----Original Message-----
> From: Scott.Oaks_at_Sun.COM [mailto:Scott.Oaks_at_Sun.COM]On Behalf Of Scott
> Oaks
> Sent: Friday, April 13, 2007 1:33 PM
> To: persistence_at_glassfish.dev.java.net
> Subject: Syntax for "IN" parameter
>
>
> I'm trying to use a named query:
>
> @NamedQuery(name="findByCountry", query="SELECT c FROM Country c WHERE
> c.id IN(:listId)")
>
> I want to set the parameter to
>
> 'UK', 'US', 'France'
>
> But nothing I try works. If I do
> q.setParameter("listId", "US")
> then I get back the results with only the US (so I know the rest of the
> code is okay). But q.setParameter("listID", "'UK', 'US', 'France'")
> fails to retrieve anything, as does q.setParameter("listID", "UK, US,
> France") and q.setParameter("\"UK\", \"US\", \"France\").
>
> -Scott