persistence@glassfish.java.net

Syntax for "IN" parameter

From: Scott Oaks <Scott.Oaks_at_Sun.COM>
Date: Fri, 13 Apr 2007 13:33:16 -0400

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