title: How to use CriteriaBuilder to call db function
body: <p>I have a string that might eventually contain spaces. I would like to replace those spaces with a regex that matches against \t,\r,\n. After replacing I would like to call regexp_like (an oracle function) to match a field against this string.</p>
  
  <p>I know it is possible to call db functions using criteria builder as described for example in <a href="https://stackoverflow.com/questions/24995881/use-regular-expressions-in-jpa-criteriabuilder">this link</a></p>
  
  <p>I am not very familiar with the difference between regex in java versus oracle or how to cobble this together (I have never called functions from criteriabuilder). Here are my tentative steps with places where I am stuck in the comments</p>
  
  <pre><code>// first replace all spaces with regex for \s,\r,\t, value is the original string
  value.replaceAll(" +", "[\\t\\n\\r]+")
  // build the db function call expression, seems I cant do table.&lt;String&gt;get(field) and cant pass value as a string
  Expression&lt;String&gt; regExp = cb.function("regexp_like", String.class, table.&lt;String&gt;get(field), value);
  // now create a predicate not sure how
  Predicate fieldMatch = cb.equal(...)
  </code></pre>
  
  <p>Is this possible?</p>