I have a simple HQL query -
from Cat where name like '%a_2%'
where I want to match the underscore rather than using it as a wildcard (default SQL behavior with some databases).
I am not sure how to escape the '_'
I tried using
nameString.replaceAll("_", "\\_");
But this doesn't seem to work.
Also I am not using Hibernate criteria. I am using named parameters for HQL queries that I am constructing directly.
(The only other reference to this issue that I could find is -
viewtopic.php?f=1&t=948181&p=2263772&hilit=escape+underscore+in+HQL#p2263772)
Help would be greatly appreciated.