Running against openjpa 1.2, I got the same error as you did. Apparently, this problem is fixed
in the trunk code.
----- Original Message ----
From: Fay Wang <fyw300@yahoo.com>
To: users@openjpa.apache.org
Sent: Mon, November 9, 2009 9:09:04 AM
Subject: Re: Unexpected ArgumentException using 'IN' operator
Hi,
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();
emp.setId(1);
q.setParameter("emp", emp);
-Fay
----- Original Message ----
From: Vivien Barousse <barousse.vivien@gmail.com>
To: users@openjpa.apache.org
Sent: Sun, November 8, 2009 7:23:44 AM
Subject: Unexpected ArgumentException using 'IN' operator
Hi,
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 :
@Entity
public class Entry implements Serializable {
@Id
private Long id;
@ManyToMany
@JoinTable
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(QueryImpl.java:287)
at org.apache.openjpa.persistence.QueryImpl.validateParameters(QueryImpl.java:274)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:248)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294)
...
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?
Thanks,
--
Vivien Barousse
|