I'm sure this is an easy one.
I've got a list of strings that I want to use as a parameter for a query:
Code:
String[] list = {'A', 'B', 'C'};
entityManager.createQuery("select a from ObjectA as a where a.field IN :list").setParameter("list", list).getResultList();
If I try to use the query as above it throws a org.hibernate.hql.ast.QuerySyntaxException. It doesn't like a parameter being used with the "IN" keyword.
My (nasty) workaround is:
Code:
String list = "('A', 'B', 'C')";
entityManager.createQuery("select a from ObjectA as a where a.field IN "+list).getResultList();
Have I missed something or can you not pass a parameter to an IN?
Thanks,
Damian.