title: Hibernate HQL Query to get parent + children based on childID
body: <p>I have an object with several @onetomany relationships, and I need to query for properties in the parent, as well as properties of the children. I can't seem to get it done.</p>
  
  <p>For example, I need a query that lets me see the Parent objects where where the parent's name is "John" <em>and</em> the child's favorite color is blue. Hope that makes sense. The reason for the complication seems to be that children are in a list, not in a @onetoone relationship.</p>
  
  <pre><code>PARENT:
  @Entity
  @Table(name="Parent")
  public class Parent {
      @Id
      @Column(name="ID")
      @GeneratedValue(strategy=GenerationType.AUTO, generator="parent_gen")
      @SequenceGenerator(name="parent_gen", sequenceName="PARENT_SEQUENCE")
      private int parentID;
  
      @Column(name="name")
      private String name;
  
      @OneToMany(cascade=CascadeType.ALL)
      @OrderBy("name ASC")
      @JoinTable(name = "parent_to_child")
      private List&lt;Child&gt; childList;
      // and so forth
  
  Child 
  @Entity
  @Table(name="Child")
  public class Child{
      @Id
      @Column(name="ID")
      @GeneratedValue(strategy=GenerationType.AUTO, generator="child_gen")
      @SequenceGenerator(name="child_gen", sequenceName="CHILD_SEQUENCE")
      private int childID;
  
      @Column(name="favoriteColor")
      private String favoriteColor;
  
      // and so forth
  </code></pre>