You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Vivien Barousse <ba...@gmail.com> on 2009/11/08 16:23:44 UTC
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
Re: Unexpected ArgumentException using 'IN' operator
Posted by ynov <y....@gmail.com>.
Fay Wang wrote:
>
> Running against openjpa 1.2, I got the same error as you did. Apparently,
> this problem is fixed in the trunk code.
>
Hi, I'm using openjpa 1.2.1 version and I'm having problems with query
parameters validation, the exception looks pretty much close to the one that
is described here. As I can see, there was a fix for this problem in
revision 686905 in 1.2.x branch
(openjpa/branches/1.2.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/QueryImpl.java,
validateParameters() method). But this fix was rolled back in revision
687120. What was the reason for rolling back this fix in 1.2.x, but it's
still present in 1.3.x?
--
View this message in context: http://n2.nabble.com/Unexpected-ArgumentException-using-IN-operator-tp3968479p4238086.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Unexpected ArgumentException using 'IN' operator
Posted by Fay Wang <fy...@yahoo.com>.
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 <fy...@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 <ba...@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
Re: Unexpected ArgumentException using 'IN' operator
Posted by Fay Wang <fy...@yahoo.com>.
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 <ba...@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