Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPA Named Parameters, with collections

843830Feb 21 2007 — edited Feb 22 2007
Hi

Is it possible with JPA to pass in a collection as named parameter into a query.

ArrayList() list = new ArrayList();
list.add("1");
lsit.add("2");

i.e. em.createNamedQuery("named").setParameter("collection",list).getResultList();

where the named query is something like

SELECT i FROM Person i WHERE i.address IN (:collection)

This throws an error: IllegalArgumentException: You have attempted to set a value of type class java.util.ArrayList for parameter collection with expected type of class java.lang.String from query

If it is possible what am i doing wrong??

Thanks

Message was edited by:
glen_
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2007
Added on Feb 21 2007
0 comments
138 views