may I ask my JPQL statement consist any error? Or the AND condition cannot work with LIKE statement?
public List searchByTime(String from, String to, String a){
Query q = em.createQuery("SELECT e FROM EnrollmentDetails e WHERE (e.startTime >= ?1 AND e.endTime <= ?2) AND (e.offerCode.offerCode LIKE: ?3)");
q.setParameter(1, from);
q.setParameter(2, to);
q.setParameter(3, a + "%");
List l = q.getResultList();
return l;
}
Whenever I remove AND (e.offerCode.offerCode LIKE: ?3)
and
q.setParameter(3, a + "%");
, then the statement is work, but without the result what I want.
I'm pretty sure the 2 statements that I removed are correct as they work in other function.
Just in this function is not working. Can anyone help me.
thank you.
You have a colon :
just after the LIKE
keyword which is illegal. A :
can only be used as part of a named parameter. Remove that and it likely will work