title: JPA Criteria API Specification JOIN by condition and result isn't null
body: <p>The code example:</p>
  
  <pre><code>@Entity
  public class Event {
  
  @Id
  @GeneratedValue
  private Long id;
  private String name;
  @OneToMany(...)
  private List&lt;Actions&gt; actions;
  
  }
  
  
  @Entity
  public class Action {
  
  @Id
  @GeneratedValue
  private Long id;
  private String name;
  private Date date;
  @ManyToOne
  @JoinColumn(name = "event_id")
  private Event event;
  
  }
  
  public class EventSpecification {
  
  public static Specification&lt;Event&gt; findByCriteria(EventSearchCriteria criteria) {
  
      return (root, criteriaQuery, criteriaBuilder) -&gt; {
          List&lt;Predicate&gt; predicates = new ArrayList&lt;&gt;();
  
          criteria.getEventName().ifPresent(name -&gt;
                  predicates.add(criteriaBuilder.equal(criteriaBuilder.lower(root.get(Event_.name)), name)));
  
          criteria.getDate().ifPresent(date -&gt; 
          // Need one more Predicat - event.has.actions.with.date.equals.criteria.date
          );
  
          return criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
      };
  }
  }
  </code></pre>
  
  <p><strong>The question is:</strong></p>
  
  <p>How to create the Predicate - only Events which have Actions with Action.date = searchCriteria.date. I think it's possible but I can't find a solution.</p>