Hi,
  This use case is better served by IN expression. There is no need to
expand the elements of parameter collection and append them dynamically. The
MEMBER OF expression accepts a collection valued path expression and can not
be parametrized by a collection.

  The following works:

  String jpql = "select p from Person p where p.nickname in (:coll)";
  Collection param = Arrays.asList(new String[]{"a","b","c"});
  em.createQuery(jpql)
      .setParameter("coll", param)
      .getResultList();

  will return Person instances whose nickname happens to be either "a","b"
or "c".

  Few notes:
  1. Notice the parentheses around :coll
  2. p.name of course be type compatible with elements of collection
parameter. 
  3. Following parameter settings are incorrect:
       String param = "a,b,c";
     or
       String[] param = new String[]{"a","b","c"};



-- 
View this message in context: 
http://n2.nabble.com/collection.contains%2C-member-of--tp1343261p1353871.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to