title: Spring-Data-JPA with QueryDslPredicateExecutor and Joining into a collection
body: <p>Let's say I have a data model like this (pseudocode):</p>
  
  <pre><code>@Entity
  Person {
      @OneToMany
      List&lt;PersonAttribute&gt; attributes;
  }
  
  @Entity
  PersonAttribute {
      @ManyToOne
      AttributeName attributeName;
  
      String attributeValue;
  }
  
  @Entity
  AttributeName {
      String name;
  }
  </code></pre>
  
  <p>I have a Spring-Data-JPA repository defined such as:</p>
  
  <pre><code>public interface PersonRepository extends PagingAndSortingRepository&lt;Person, Long&gt;, QueryDslPredicateExecutor&lt;Person&gt;{}
  </code></pre>
  
  <p>I see in the QueryDSL documentation that there is a mechanism to Join from the Person to the  PersonAttribute, but it looks like you need access to the QueryDsl Query object, which the client of the repository wouldn't have.</p>
  
  <p>What I would like to do with my Predicate is to find all those Persons that have an AttributeValue (there's one join) with a value of "blue" and an AttributeName (there's another join) with a name of "eyecolor".  I'm not sure how I would do that with an <code>any()</code> and enforce that I only get those with eye_color=blue and not those with shoe_color=blue.</p>
  
  <p>I was hoping I could do something like this:</p>
  
  <pre><code>QPerson person = QPerson.person;
  QPersonAttribute attribute = person.attributes.any();
  
  Predicate predicate = person.name.toLowerCase().startsWith("jo")
      .and(attribute.attributeName().name.toLowerCase().eq("eye color")
            .and(attribute.attributeValue.toLowerCase().eq("blue")));
  </code></pre>
  
  <p>but with the <code>any()</code> in there it just matches anything with an attribute value of "blue" and anything with an "eye color" attribute regardless of color.  <strong>How I can make those conditions apply to the same attribute within the set?</strong></p>