persistence@glassfish.java.net

Re: Problem binding collections to queries

From: Mitesh Meswani <Mitesh.Meswani_at_Sun.COM>
Date: Thu, 07 Feb 2008 10:02:58 -0800

JPA 1.0 does not allow this. It should be nice to have this working.

Work on JPA 2.0 is under way. You can send a comment to JPA2.0 expert
group (jsr-317-comments_at_jcp.org)to add this feature to the spec.

Christian Kerwer wrote:
>
> Hi everyone
>
> I’m trying to bind a collection of Ids into a Query like this:
>
> Select p from Project p where p.id IN (:IdList)
>
> with IdList as Array of Long and field p.id of type Long.
>
> It will be quitted with the following exception:
>
> java.lang.ClassCastException:
>
> You have attempted to set a value of type class [Ljava.lang.Long; for
> parameter planningObjectIdList with expected type of class
> java.lang.Long from query string select planObjStrLnk from
> PlanningObjectStructureLink planObjStrLnk where
> planObjStrLnk.planningClassStructure.id = :planningClassStructureId
> and planObjStrLnk.planningObject.id in (:planningObjectIdList)
>
> Any Idea?
>
> Christian Kerwer
>