users@glassfish.java.net

invalid query generated by EclipseLink when using LIKE expression

From: Sarah kho <sarah.kho_at_gmail.com>
Date: Tue, 25 Aug 2009 14:17:02 +0430

Hi
I am using EclipseLink 3 preluage with my Java SE application. my code to
prepare a query is as follow:
q = em.createQuery("SELECT B FROM Branch B WHERE B.street LIKE :street");
 q.setParameter("street", "'%a%'");

And the generate SQL statement as shown in the log is like:
SELECT ID, STREET FROM BRANCH WHERE (STREET LIKE CAST (? AS VARCHAR(32672)
))
  bind => [%a%]

I think the generated SQL statement is incorrect or somehow it does not work
well with Derby, because I receive no result for my JPA QL, while if I
execute it as a simple SQL statement I get tens of rows in the restultset.
Am I missing something here? Is that generated SQL correct?
Thanks.