[英]JPQL work with LIKE statement and AND condition
may I ask my JPQL statement consist any error? 我可以问我的JPQL语句是否包含任何错误? Or the AND condition cannot work with LIKE statement?
或AND条件不能与LIKE语句一起使用?
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 + "%");
每当我删除
AND (e.offerCode.offerCode LIKE: ?3)
和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. 我很确定我删除的2条语句在其他函数中是正确的。
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. 您有一个冒号
:
在LIKE
关键字之后,这是非法的。 A :
can only be used as part of a named parameter. A
:
只能用作命名参数的一部分。 Remove that and it likely will work 删除它,可能会起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.