I\'m trying to implement a web service which accepts a list of strings, each of which is a regular expression. These need to be compared against six columns of a database,
Similar working example
Criterion criterion = Restrictions.sqlRestriction("regexp_like (column_name, ?, 'i')", "(^|\\s)"+searchValue+"($|\\s|.$)", StringType.INSTANCE);
There's nothing in the hibernate docs for performing regular expression queries (using HQL or Criteria queries). The approach using the sqlRestrictions
should probably be changed to one of the overloaded methods to avoid a SQL Injection vulnerability.
Example code:
Restrictions.sqlRestriction("regexp_like({alias}.NODE_1, ?)", re, Hibernate.STRING)