2 Replies Latest reply on May 6, 2005 3:36 PM by Robin Young

    NamedQuery with IN bind variable

    Robin Young Newbie

      I have the following named query at the top of my @Entity annottated class:-

       @NamedQuery(name = "InnerTemplate_find", queryString = "SELECT record FROM InnerTemplate AS record WHERE securityRole IN (:securityRoles)")
      


      I have tried

      this.manager.createNamedQuery("InnerTemplate_find").setParameter("securityRoles", "'a','b'").getResultList();
      


      and also

      List<String> roles = new ArrayList<String>();
      roles.add('a');
      roles.add('b');
      this.manager.createNamedQuery("InnerTemplate_find").setParameter("securityRoles", roles).getResultList();
      


      but neither seem to work.

      It is possible to pass an array of strings into a named query as a parameter? Have I got the syntax for the named query wrong?

      Note: the size and contents of the array will vary dynamically at runtime and thus
      IN ('a','b')

      will not suffice.