Using hibernate criteria, is there a way to escape special characters?

前端 未结 5 1119
天涯浪人
天涯浪人 2020-12-03 03:19

For this question, we want to avoid having to write a special query since the query would have to be different across multiple databases. Using only hibernate criteria, we w

5条回答
  •  盖世英雄少女心
    2020-12-03 03:59

    If you use sqlRectrictions, the correct way to do it is the following:

    criterions.add(Restrictions.sqlRestriction(columnName+" LIKE '!%' ESCAPE '!'"));

    Is like a sql query, doesn't work ilike => use LIKE using Oracle 12i.

提交回复
热议问题