How to escape wildcard characters in "like" clause in HQL?

Posted by Pablo Cabrera on Stack Overflow See other posts from Stack Overflow or by Pablo Cabrera
Published on 2010-06-09T13:58:55Z Indexed on 2010/06/09 14:02 UTC
Read the original article Hit count: 413

Filed under:
|
|
|

How can I escape the wildcard characters in a like clause?

E.g.:

select foo from Foo as foo where foo.bar like '%' || :filter ||'%'
query.setParameter("filter", "%");
query.list(); 
// I'd expect to get the foo's containing the '%' in bar, not all of them!

Any ideas?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about hql