JPQL中使用LIKE进行模糊查询

方法1:

SELECT 
  e
FROM 
  entity e
WHERE
  (0 < LOCATE(:searchStr, e.property))

函数LOCATE(searchString, candidateString [, startIndex]),用于查找目标字符串searchString在候选字符串candidateString中的下标index(从1开始,非0开始)。

方法2:

SELECT 
  e
FROM 
  entity e
WHERE
  (0 < CONCAT(:searchStr, '%'))

函数CONCAT(string1, string2),用于连接两个表字段或常量。

转载于:https://my.oschina.net/yqz/blog/876153