title: JPA/Criteria API - Like & equal problem
body: <p>I'm trying to use Criteria API in my new project:</p>
  
  <pre><code>public List&lt;Employee&gt; findEmps(String name) {
      CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery&lt;Employee&gt; c = cb.createQuery(Employee.class);
      Root&lt;Employee&gt; emp = c.from(Employee.class);
      c.select(emp);
      c.distinct(emp);
      List&lt;Predicate&gt; criteria = new ArrayList&lt;Predicate&gt;();
  
      if (name != null) {
          ParameterExpression&lt;String&gt; p = cb.parameter(String.class, "name");
          criteria.add(cb.equal(emp.get("name"), p));
      }
  
      /* ... */
  
      if (criteria.size() == 0) {
          throw new RuntimeException("no criteria");
      } else if (criteria.size() == 1) {
          c.where(criteria.get(0));
      } else {
          c.where(cb.and(criteria.toArray(new Predicate[0])));
      }
  
      TypedQuery&lt;Employee&gt; q = em.createQuery(c);
  
      if (name != null) {
          q.setParameter("name", name);
      }
  
      /* ... */
  
      return q.getResultList();
  }
  </code></pre>
  
  <p>Now when I change this line:</p>
  
  <pre><code>            criteria.add(cb.equal(emp.get("name"), p));
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>            criteria.add(cb.like(emp.get("name"), p));
  </code></pre>
  
  <p>I get an error saying: </p>
  
  <blockquote>
    <p>The method like(Expression, Expression) in the type CriteriaBuilder is not > applicable for the arguments (Path, ParameterExpression)</p>
  </blockquote>
  
  <p>What's the problem?</p>