Hi Scott,
I'm afraid what you need is not supported by the Java Persistence query
language. I understand you would like to pass a list of id values as a
parameter to the query and then use the list parameter in the
IN-expression. I think this is not supported. The spec says the IN
expression items are either literals or input parameters and they need
to have the same type as the state field path expression left of the IN
keyword. The only thing you can do is define multiple input parameters
and include them all in the IN clause: c.id IN (:param1, :param2, :param3)
Regards Michael
> 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
>