openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fay Wang <>
Subject Re: Unexpected ArgumentException using 'IN' operator
Date Mon, 09 Nov 2009 17:09:04 GMT
        I tried the following using openjpa trunk, and it works fine. I will try it using
openjpa 1.2. 

 Query q =
            em.createQuery("Select m from Manager m, IN (m.employees) emps where emps = :emp");
        Employee emp = new Employee();
        q.setParameter("emp", emp);


----- Original Message ----
From: Vivien Barousse <>
Sent: Sun, November 8, 2009 7:23:44 AM
Subject: Unexpected ArgumentException using 'IN' operator


I'm having trouble using the IN operator in OpenJPA 1.2.1.

In my application, I have an entity named 'Entry', which has a many to many relationship to
itself on a 'parentEntries' field. Here is the (simplified) code for this entity :

public class Entry implements Serializable {

   private Long id;

   private List<Entry> parentEntries;

   /* ... getters and setters ... */


I'm trying to retrieve all entities which parentEntries contains any given entry (passed as
argument to my query). Here is the query:

SELECT entry FROM Entry AS entry, IN (entry.parentEntries) AS parent WHERE parent = :entry

This query fails on execution, with an ArgumentException :
<openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
The parameter "entry" is of type "com.aperigeek.jtentative.entity.Entry", but the declaration
in the query is for type "java.util.List"
       at org.apache.openjpa.persistence.QueryImpl.validateParameter(
       at org.apache.openjpa.persistence.QueryImpl.validateParameters(
       at org.apache.openjpa.persistence.QueryImpl.execute(
       at org.apache.openjpa.persistence.QueryImpl.getResultList(

This query works fine with other persistence provider (the above code has been successfully
tested with Toplink).

Am I missing something here? I saw in an old bug report (#OPENJPA-190) someone having the
same difficulties.
Could this be an OpenJPA bug?


Vivien Barousse


View raw message