How do I use LIKE %
in Hibernate. I want to use a SQL with LIKE %
in my hbm.xml
file. I have 2 queries which I am consolidating to 1.
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: