title: How to JPA join from child element
body: <p>I want to select elements via JPA query/criteriaQuery but can't quite figure out how to do it.</p>
  
  <p>I'm using H2 as the DB. The query i've tested in H2 console is:</p>
  
  <pre><code>SELECT element.* 
  FROM element LEFT JOIN group_element ON element.id  = group_element.elements_id
  WHERE group_id IS NULL
  </code></pre>
  
  <p>In other words i want to select groupless elements.</p>
  
  <p>Classes are:</p>
  
  <pre><code>@Entity
  class Element{
      @Id
      @GeneratedValue
      private Integer id;
  }
  
  @Entity
  class Group{
      @Id
      @GeneratedValue
      private Integer id;
  
      @ManyToMany
      private List&lt;Element&gt; elements;
  }
  </code></pre>
  
  <p>I've had no problem doing this in similar cases where "elements" were mapped by field in Element, but in this specific case i can't add that field. I can't quite figure out how to join the entities in this case.</p>