title: JPA CriteriaBuilder substring with Expression
body: <p>I have a CriteriaBuilder where I am trying to get characters starting from 1 to (LengthOfString - 5). However I am not able to get the desired output. Below is my desired output. </p>
  
  <pre><code>select
              *
          from tbl_job job1_     
  
          inner join
              tbl_customer customer2_ 
                  on job1_.customer_id=customer2_.id 
          where
              job1_.customer_id=customer2_.id 
                      and //
  
          group by SUBSTRING(job1_.code,1,(LENGTH(job1_.code)-5))
  </code></pre>
  
  <p>And I have tried this way, but my IDE depict the error under the <strong>(cb.length(root.get("code"))-5)</strong> "The operator - is undefined for the argument type(s) Expression, int".</p>
  
  <pre><code>final Specification&lt;Job&gt; specification = (root, query, cb) -&gt; {
              query.orderBy(cb.asc(root.get("code"))); 
              query.groupBy(cb.substring(root.get("code"), 1 , (cb.length(root.get("code"))-5) ));
              return cb.and(
                      //...
          };
  </code></pre>
  
  <p>hat could be the reason for this?
  Thanks for any help advance.</p>