title: JPA query filter on concatenated fields
body: <p>I want to query my "customers" table using "name + surname" string as a key.</p>
  
  <p>Name and surname are stored in different fields.</p>
  
  <p>So my query would be:</p>
  
  <pre><code>SELECT 
     * 
  FROM 
     customers 
  WHERE 
     CONCAT(name,' ',surname) LIKE '%term%' 
     OR CONCAT(surname,' ',name) LIKE '%term%' 
  </code></pre>
  
  <p>However, I can't do that, my query is a JPA2 <strong>criteria query</strong>. Something like:</p>
  
  <pre><code>CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
              CriteriaQuery cq = cb.createQuery();
              Root&lt;Customer&gt; from = cq.from(Customer.class);
              cq.select(from);
  
              Predicate whereClause = cb.or(
                  cb.like(from.&lt;String&gt;get("name"), "%"+ r +"%"),
                  cb.like(from.&lt;String&gt;get("surname"), "%"+ r +"%"),
              );
  
              cq.where(whereClause);      
              TypedQuery&lt;Customer&gt; query = getEntityManager().createQuery(cq);
              list = query.getResultList();
  </code></pre>
  
  <p>How can I filter my result set by the combination of name and surname, please?</p>