Using LIKE % in Hibernate

扶醉桌前 提交于 2019-12-02 00:50:58

Maybe the user_id is not a char/varchar? You have to convert the user_id with str() to character data first!

Example:

SELECT *
FROM abc.def_vw a
WHERE user_id = ?
AND str(user_id) LIKE '%' || ?

Use LIKE '%?%' and second parameter string to make the query. The field also should be a string type because like is used to compare strings.

3 things to notice:

  • Is user_id string?
  • like in HQL works fine. for example like '%something%'
  • Your query doesn't make sense "where user_id =? and user_id like '%'" what are you trying to do ? Use only one of the conditions.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!