This is failing:
List<String> names = new ArrayList<String>();
names.add("sold");
Query query = em.createQuery("FROM PropField propField WHERE propField.name IN (?)");
query.setParameter(1, names);
List<PropField> fields = query.getResultList();
And so is this:
List<String> names = new ArrayList<String>();
names.add("sold");
Query query = em.createQuery("FROM PropField propField WHERE propField.name IN (?)");
query.setParameter(1, names.toArray());
List<PropField> fields = query.getResultList();
This, too:
List<String> names = new ArrayList<String>();
names.add("sold");
Query query = em.createQuery("FROM PropField propField WHERE propField.name IN ?");
query.setParameter(1, names.toArray());
List<PropField> fields = query.getResultList();
And every other permutation of the above. Checked the docs and it says the first option should work. Here’s the exception for the top one.
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String
at org.hibernate.type.StringType.toString(StringType.java:67)
Hibernate’s HQL uses setParameterList, but trying to stick with straight JPA here.
I ran into a similar problem with Hibernate using a JPA named query with an IN clause. I got it working with the syntax: “propField.name IN (?1)”
Also see: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4922
and http://opensource.atlassian.com/projects/hibernate/browse/HHH-5126