Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
0.9.7
-
None
-
None
Description
According to the JPA 1.0 spec - 4.6.4.1 Positional Parameters - p. 90:
Note that the same parameter can be used more than once in the query string and that the ordering of the use of parameters within the query string need not conform to the order of the positional parameters.
So, keeping it in mind, I can't explain why the following fails:
Query query = em.createQuery("SELECT DISTINCT o FROM Osoba o, IN(o.projekty) p WHERE o.imie LIKE ?2 AND p.rodzajProjektu = ?1");
query.setParameter(1, RodzajProjektu.OTWARTY);
query.setParameter(2, "J%");
with the following error:
-------------------------------------------------------------------------------
Test set: pl.jaceklaskowski.jpa.chapter4_6.ConditionalExpressionsTest
-------------------------------------------------------------------------------
Tests run: 3, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.203 sec <<< FAILURE!
testPositionalParameters(pl.jaceklaskowski.jpa.chapter4_6.ConditionalExpressionsTest) Time elapsed: 0.125 sec <<< FAILURE!
<4|false|0.9.7-incubating-SNAPSHOT> org.apache.openjpa.persistence.ArgumentException: The parameter "1" is of type "java.lang.String", but the declaration in the query is for type
"pl.jaceklaskowski.jpa.entity.RodzajProjektu".
at org.apache.openjpa.persistence.QueryImpl.validateParameter(QueryImpl.java:257)
at org.apache.openjpa.persistence.QueryImpl.validateParameters(QueryImpl.java:237)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:218)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:264)
at pl.jaceklaskowski.jpa.chapter4_6.ConditionalExpressionsTest.testPositionalParameters(ConditionalExpressionsTest.java:115)
I have tested it out against Hibernate EntityManager 3.3.0.GA and TopLink Essentials 2.0 BUILD 40 and I don't see the trouble there.