Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] jpql named parameter list as input does not work

It definitely should not have brackets, brackets would mean you are binding a
value inside the list, not the entire list.  This is the JPA 2.0 grammar.


Thomas Rost wrote:
> 
> We use JPA 1.0/EclipseLink 1.2 RC3 and it does not work.
> We found out it works without the brackets in the query: X IN :BUID
> instaed of X IN (:BUID).
> 
> Question: It's a feature or a bug? In Hibernate brackets are mandatory.
> 
> 
> James Sutherland wrote:
>> 
>> This was not supported in JPA 1.0/EclipseLink 1.1, but is supported in
>> JPA 2.0/EclipseLink 2.0/1.2.
>> 
>> What version are you using?
>> 
>> 
>> 
>> Thomas Rost wrote:
>>> 
>>> We try to pass named parameter as a list in a jpql query. But we get the
>>> following error:
>>> 
>>> {SELECT returnValue FROM Need returnValue WHERE  returnValue.type  =
>>> '001' and  (  returnValue.type  = :type or  returnValue.BUID  IN (:BUID) 
>>> ) }
>>> 
>>> {SELECT returnValue FROM Need returnValue WHERE returnValue.type  =
>>> '001' and  (  returnValue.type  = :type or  returnValue.BUID  IN (:BUID) 
>>> ) }
>>> 
>>>  INFO Caused by: java.lang.IllegalArgumentException: You have attempted
>>> to set a value of type class java.util.ArrayList for parameter BUID with
>>> expected type of class java.lang.String from query string 
>>> 
>>> SELECT returnValue FROM Need returnValue WHERE  returnValue.type  =
>>> '001' and  (  returnValue.type  = :type or  returnValue.BUID  IN (:BUID) 
>>> ) .
>>> 
>>>  INFO   at
>>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameterInternal(EJBQueryImpl.java:975)
>>>  INFO   at
>>> org.eclipse.persistence.internal.jpa.EJBQueryImpl.setParameter(EJBQueryImpl.java:862)
>>>  ...
>>> 
>>> Info: it works with hibernate and we have a workaround by transforming
>>> list content into a comma separated string.
>>> 
>>> Question: Bug or wrong usage of named parameter?
>>> 
>>> Kind regards,
>>> Tom
>>> 
>> 
>> 
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/jpql-named-parameter-list-as-input-does-not-work-tp25678654p25803240.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top