title: Criteriabuilder like, how to do it for Long?
body: <p>i try use "like" method from Criteriabuilder for get all record based on pattern " 10% ".</p>
  
  <p>I want get record where ID is - 101, 10002, 1003,1000 etc...</p>
  
  <p>I've use this code:</p>
  
  <pre><code>Predicate p = cb.like(r.&lt;String&gt;get("ID").as(String.class), "10%")
  </code></pre>
  
  <p>but i got Exception where i see what postgres can't execute query like this:</p>
  
  <pre><code>SELECT ID, NAME, SOMETHING FROM TABLE WHERE ID LIKE 10%
  </code></pre>
  
  <p><strong>That is JPA (Glassfish 4.x) generate wrond query.</strong></p>
  
  <p>Right query must like that : </p>
  
  <pre><code>SELECT ID, NAME, SOMETHING FROM TABLE WHERE CAST (ID as TEXT) LIKE '10%'
  </code></pre>
  
  <p>How to build query via Criteria API that i got a right query for postgres ?</p>
  
  <p><strong>Updated:</strong></p>
  
  <p>I try write a CAST function :</p>
  
  <pre><code>Expression&lt;String&gt; postgresqlCastFunction = cb.function("CAST", String.class, r.&lt;String&gt;get("ID").as(String.class));
  Predicate p = cb.like(postgresqlCastFunction, "10%");
  </code></pre>
  
  <p>but got a query like this :</p>
  
  <pre><code>FROM TABLE WHERE (CAST(ID) LIKE ?)
  </code></pre>
  
  <p>, so, how to add need expression in function for this right result - </p>
  
  <p>FROM TABLE WHERE (CAST(ID <strong>as TEXT</strong>) LIKE ?) ..</p>