[ 
https://issues.apache.org/jira/browse/OPENJPA-188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484772
 ] 

Marc Prud'hommeaux commented on OPENJPA-188:
--------------------------------------------

What is the type of the "rodzajProjektu" field? If it really is the 
RodzajProjektu entity, then you cannot compare a String to an Object. If you 
are wanting to query against a field (e.g., the id field) of the entity, then 
you would do "p.rodzajProjektu.someField = ?1".

> 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.

Reply via email to