title: Use Regular Expressions in JPA CriteriaBuilder
body: <p>I'm using the JPA CriteriaBuilder to select entities of type <code>MyEntity</code> from a MySQL db as follows:</p>
  
  <pre><code>String regExp = "(abc|def)"
  CriteriaBuilder cb = em.getCriteriaBuilder();
  CriteriaQuery query = cb.createQuery( MyEntity.class );
  root = query.from( MyEntity.class );
  predicates = new ArrayList&lt;Predicate&gt;();
  
  predicates.add( cb.like( root.&lt;String&gt;get( "name" ), regExp ) );
  </code></pre>
  
  <p>Thus, the query result should contain any entity where the <code>name</code> value matches the given regExp. But the result list is always empty.
  Changing the regExp to <code>/(abc|def)/g</code> has no effect, neither does adding the wildcard <code>%</code></p>
  
  <p>How to make the pattern matching work?</p>
  
  <p>Alternatively: How can I use native MySQL REGEXP together with the CriteriaBuilder?</p>