openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacek Laskowski (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-188) Positional parameters (in)order within query and query.setParameter (in)order
Date Wed, 28 Mar 2007 07:56:32 GMT
Positional parameters (in)order within query and query.setParameter (in)order
-----------------------------------------------------------------------------

                 Key: OPENJPA-188
                 URL: https://issues.apache.org/jira/browse/OPENJPA-188
             Project: OpenJPA
          Issue Type: Bug
          Components: query
    Affects Versions: 0.9.7
            Reporter: Jacek Laskowski


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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message