title: My query to create an intersection (and) between two conditions doesn't work, why ? (Hibernate, Java, Rest Application)
body: <pre><code>@GET
  @Path("/colors/{params: .*}")
  @Produces(MediaType.APPLICATION_JSON)
  public List&lt;Espece&gt; findByColors(@PathParam("params") List&lt;PathSegment&gt; params){
      CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
      CriteriaQuery&lt;Espece&gt; cq = cb.createQuery(Espece.class);
      Root&lt;Espece&gt; birdType = cq.from(Espece.class);
      Join&lt;Espece, Couleur&gt; couleurs = birdType.join(Espece_.colors);
  
      List&lt;Predicate&gt; restrictions = new ArrayList&lt;&gt;();
      for(PathSegment param : params){
          restrictions.add(cb.equal(cb.lower(couleurs.get(Couleur_.nom)), param.toString().toLowerCase()));
      }
      cq.where(cb.and(restrictions.toArray(new Predicate[]{})));
      /*cq.select(birdType)
          .where(restrictions.toArray(new Predicate[]{}));*/
  
      return getEntityManager().createQuery(cq).getResultList();
  }
  </code></pre>
  
  <p>There is my method to search a bird with one or multiple colors (A bird can have more than one color). And when I'm searching with only one color : <em><a href="http://localhost:8084/NataRest/bird/colors/black" rel="nofollow noreferrer">http://localhost:8084/NataRest/bird/colors/black</a></em> it works fine.
  But when I'm searching with two colors : <em><a href="http://localhost:8084/NataRest/bird/colors/black/yellow" rel="nofollow noreferrer">http://localhost:8084/NataRest/bird/colors/black/yellow</a></em> it gives me an empty answer (And yes I have some birds in my database which are black and yellow).
  I checked multiple forums and still not finding a way to make this work... I can make an union with a 'or' and 'distinct'. But not a intersection like I want :/</p>
  
  <p>Thanks for advance for the help !
  Okan.</p>