title: HQL: Finding object where child objects include specific attribute values
body: <p>This is an extension of <a href="https://stackoverflow.com/questions/5838806/sql-query-one-table-based-on-join-on-another-table-that-has-multiple-matches">this</a> question.</p>
  
  <p>Instead of SQL, how would I do the same using HQL? (i.e. find all dogs that have both the colors of black and white but could have other colors)</p>
  
  <p>Let's say my entity classes look like this:</p>
  
  <pre><code>public class Dog {
      private Long id;
      private Set&lt;DogColor&gt; colors;
      private String name;
      private String size;
  
      ...
  }
  
  public class DogColor {
      private Long id;
      private String color;
  
      ...
  }
  </code></pre>
  
  <p>Then I want my HQL to look a little something like this:</p>
  
  <pre><code>from dog where dog.colors contains ("black", "white")
  </code></pre>
  
  <p>Obviously this is just pseudo-code since dog.colors is an object and not the color strings.</p>