title: JPA Criteria API with multiple parameters
body: <p>I need to make a search method that uses the JPA Criteria API with multiple parameters.
  Now the problem is that not every parameter is required. So some could be null, and they shouldn't be included in the query. I've tried this with the CriteriaBuilder but I couldn't see how to make it work.</p>
  
  <p>With the Hibernate Criteria API this is fairly easy. Just create the criteria and then add Restrictions.</p>
  
  <pre class="lang-java prettyprint-override"><code>Criteria criteria = session.createCriteria(someClass.class);
  if(someClass.getName() != null) {
     criteria.add(Restrictions.like("name", someClass.getName());
  }
  </code></pre>
  
  <p>How could I achieve the same with JPA's Criteria API?</p>