I use OpenJPA 2.1 on WebSphere Application Server with a MySQL 5 DB.
I have a list of dates and want to use the IN operator to get only the entries from DB where the date in DB is also in the list.
List<Date> dates = new LinkedList<Date>();
dates.add(somedates);
My query looks like this:
List<Object> list = em
.createNativeQuery(
"SELECT w.date FROM week_table w WHERE w.date IN ?1")
.setParameter(1, dates).getResultList();
But I get an ArgumentException: org.apache.openjpa.persistence.argumentexception the specified parameter of type is not a valid query parameter
Exception in thread "main" <openjpa-2.1.1-SNAPSHOT-r422266:1141200 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:org.apache.openjpa.persistence.argumentexception the specified parameter of type "class java.util.LinkedList" is not a valid query parameter.
at org.apache.openjpa.jdbc.sql.DBDictionary.setUnknown(DBDictionary.java:1426)
at org.apache.openjpa.jdbc.kernel.SQLStoreQuery$SQLExecutor.executeQuery(SQLStoreQuery.java:218)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1005)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:315)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:331)
So how can I pass a List or the List Values into my query?
Best Regards Veote