title: Java JPA2 Predicate
body: <p>I am using Java8 and JPA2.</p>
  
  <p>I would like to add a predicate to a where clause.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>@Override
  public List&lt;Job&gt; findById(String ids, Integer type) {
  
      String[] args = ids.split(",");
      Set&lt;String&gt; idSet = new HashSet&lt;String&gt;(Arrays.asList(args));
  
      CriteriaBuilder builder = entityManager.getCriteriaBuilder();
      CriteriaQuery&lt;Job&gt; query = builder.createQuery(Job.class);
      Root&lt;Job&gt; post = query.from(Job.class);
      CriteriaQuery&lt;Job&gt; criteria = query.select(post);
      criteria.where(post.get("id").in(idSet));
      //criteria.where(post.get("type").in(type));  &lt;=== how do I do an equals
      TypedQuery&lt;Job&gt; typedQuery = entityManager.createQuery(query);
      List&lt;Job&gt; results = typedQuery.getResultList();
      return results;
  }
  </code></pre>
  
  <p>As you can see, I use a <code>criteria</code> object and have a <code>where</code> clause that filters on "ids" in the id set.</p>
  
  <p>I would like to add an addition filter to the where clause, but am not sure how to. I would like to add a clause where column "type" equals the value in the <code>type</code> Integer object.</p>
  
  <p>i.e.</p>
  
  <pre><code>where id in [...] and type = 1
  </code></pre>
  
  <p>Any advise appreciated.</p>