java - List as a named parameter in JPA query using TopLink -


In the following JPA query, named parameters should be a list of integer values:

   

@NamedQuery (name = "SortTypeNWD.findByFcIds", from the query = "s Select SortTypeNWD where s.sortTypeNWDPK.fcId in (: fcIds)")

quite logical, when this The named query is called what is done:

  query findByDatesPlFcIds = em.createNamedQuery ("SortTypeNWD.findByFcIds"); FindByDatesPlFcIds.setParameter ("FCIDs", FCID);  

Where the variable is an ArrayList containing FCIds integers

All the above code works fine with Hibernate but does not do with TopLink:

  Due to: java.lang.IllegalArgumentException: Select the query string from SortTypeNWD from you s with the expected type of int parameter type fcIds for class java.util.ArrayList value (S: fcIds) in s.sortTypeNWDPK.fcId where you tried to set  

Is there any alternative way to use the list as a designated parameter in the top links? Can the type of named parameter be compelled?

Toplink applies JApA 1.0 that does not support passing the list as a parameter ( Collection_available_input_permator, word used in documentation) is supported in the JpA 2.0 which is implemented in the success of TopLink EclipseLink.

If you have to stay with TopLink then you need to write a loop to include each item in the form of a parameter list.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -