How do you send a List parameter for IN clause to a DataReadQuery?
I am trying the below code but cannot get the list param working.
String sql = “select * from myTable where col1 in (#listParam)”
final DataReadQuery query = new DataReadQuery(sql);
resultVector = (Vector<DatabaseRecord>)session.executeQuery(query, args);
Thanks for the help.
Lists will not be expanded on when using native SQL as it would require parsing and manipulating the SQL string passed in. So if you are going to use native SQL, you are going to have to add a parameter to the query for each element in the collection. EclipseLink can break up parameter collections when it controls the SQL that is generated, so you could try using EclipseLink expressions or JPQL for your query instead of an SQL string.
One of the strings being passed on as a parameter value has a # in it and TopLink thinks that it is parameter and errors out.
How can I send a parameter value that contains a #?
My query has a "And product = #product"
The value passed to the product parameter is "xxx#xyz"
You can pass in the value as a parameter instead. Another option is to change the character used for parameter delimiting. This is a property in JPA jdbc.parameter-delimiter | EclipseLink 2.4.x Java Persistence API (JPA) Extensions Reference and can be set using setParameterDelimiter on the DatabaseQuery.