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