0
我有一個基於Spring Web模型 - 視圖 - 控制器(MVC)框架的項目。 Spring Web模型 - 視圖 - 控制器(MVC)框架的版本是3.2.8。Java Persistence Query Language - LIKE
我有這個方法在我的DAO
@Override
public List<Application> findByQuickSearch(String searchString) {
final StringBuilder queryString = new StringBuilder(" select app from Application app where upper (ticket_id) like :searchString or upper (id) like :searchString ");
queryString.append(" and app.status != " + Status.DRAFT.ordinal());
queryString.append(" order by app.submissionTime desc ");
try {
final Query query = getEntityManager().createQuery(queryString.toString());
searchString = searchString.replace("!", "!!")
.replace("%", "!%")
.replace("_", "!_")
.replace("[", "![")
.trim()
.toUpperCase();
System.out.println ("searchString -----> " + searchString);
query.setParameter ("searchString", searchString);
return query.getResultList();
} catch (RuntimeException re) {
log.error("findByCompetentBodyAndStatus failed", re);
throw re;
}
}
但我意識到,查詢不很喜歡,但等於
我尋找春天是"iOS/032/027"
,確定爲"iOS/032/027"
,但不"iOS/"
或"027"