title: How to exclude a collection with a JPA query
body: <p>I'm creating a database query with JPA and need to exclude a list from the result.
  How should I do this?</p>
  
  <pre><code>public List&lt;PersonEntity&gt; getPersonsWithoutNotWanted(List&lt;Long&gt; notWantedId ) {
      CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery&lt;PersonEntity&gt; cq = cb.createQuery(PersonEntity.class);
  
      Root&lt;PersonEntity&gt; root = cq.from(PersonEntity.class);
  
      // How to add a Predicate or something else to remove all notWantedId's
  
      TypedQuery&lt;RequestableEntity&gt; query = em.createQuery(cq);
      return query.getResultList();
  }
  </code></pre>