JPQL IN clause: Java-Arrays (or Lists, Sets…)?

I’m not sure for JPA 1.0 but you can pass a Collection in JPA 2.0: String qlString = “select item from Item item where item.name IN :names”; Query q = em.createQuery(qlString, Item.class); List<String> names = Arrays.asList(“foo”, “bar”); q.setParameter(“names”, names); List<Item> actual = q.getResultList(); assertNotNull(actual); assertEquals(2, actual.size()); Tested with EclipseLInk. With Hibernate 3.5.1, you’ll need to … Read more

tech