title: Hibernate Criteria Query to use MySQL REPLACE and CONCAT functions
body: <p>Trying to replicate the following MySQL query in Hibernate using <code>CriteriaBuilder</code>. This query adds first and last name, removes all whitespaces in between and search for results that matches the given string.</p>
  
  <p><code>select * from users where replace(concat(first_name, last_name), " ", "") like 'jamesbon%';</code></p>
  
  <pre><code>final CriteriaBuilder criteriaBuilder = getCurrentSession().getCriteriaBuilder();
  final CriteriaQuery&lt;UserImpl&gt; userCriteriaQuery = criteriaBuilder.createQuery(UserImpl.class);
  
  final Root&lt;UserImpl&gt; userRoot = userCriteriaQuery.from(UserImpl.class);
  
  // criteriaBuilder.concat(userRoot .get("firstName"), userRoot .get("lastName"))
  </code></pre>