Hello,
I am trying to do the following query:
Code:
items.addAll(createQuery("from "+ Item.class.getName() + " where (lower(TAGS) like :tag) order by id desc").setParameter("tag", '%' + tags[i] + '%').getResultList());
This essentially means that I might be having TAGS where there will be '_', '%', '$', or any other special characters embedded/prefixed/suffixed to a word. When I execute my query, I get wrong results (all the items in database, not specific items). I understand that '_' and '%' are wildcard characters, but surely there is a way to escape it.
I tried to use the ESCAPE predicate but it didn't work as well.
How can I resolve the problem?