I'm using Netbeans 7.3, Glassfish 3.1.2.2 to develop an aplication that connects to an AS400 using EclipseLink JPA 2.0. All queries work properly, until I get to a particular NamedQuery:
SELECT u FROM Table1 u WHERE u.field1 IN (:field1)
AND SUBSTRING(u.field2,3,1) IN (:hack) AND
SUBSTRING(u.field3,2,2) IN (:field3) ORDER BY u.field1
The parameters are set as follows:
Query query = getEntityManager().createNamedQuery("Table1.findAllWithRestrictions").setParameter("hack", "'S','C'").setParameter("field1", start).setParameter("field3", finish);
The query executes but returns with an empty list. Turning on logging gives me the generated SQL:
SELECT FIELD1, FIELD2, FIELD3, FIELD4, FIELD5, FIELD6
FROM ABC.DATAB.TABLE1 WHERE (((FIELD1 IN ('00')) AND
(SUBSTR(FIELD2, 3, 1) IN ('S','C'))) AND
(SUBSTR(FIELD3, 2, 2) IN ('0S'))) ORDER BY FIELD1 ASC
Running this generated SQL against the same database connection returns several rows. There is no exception thrown in the logs anywhere, only an empty ResultList. What could I be doing wrong?