title: JPA Criteria Set/List not usable as PluralAttribute to make a Predicate
body: <p>I have an entity class X which has a collection of Y entities. </p>
  
  <p>X</p>
  
  <pre><code>@ManyToMany
  private List&lt;Y&gt; items = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>I'm trying to make a JPA criteria query restriction to test if an instance of Y exists in the collection.</p>
  
  <pre><code>X entity = ...; // Some instance
  Predicate p = criteriaBuilder.isMember(entity, subRoot.get(X_.items))
  </code></pre>
  
  <p>Gives me an error of: 
  <code>(argument mismatch; ListAttribute&lt;X,Y&gt; cannot be converted to PluralAttribute&lt;X,C,E&gt;))</code></p>
  
  <p>When I look at the metamodel the List attribute is like this:</p>
  
  <pre><code>public static volatile ListAttribute&lt;X, Y&gt; items;
  </code></pre>
  
  <p>Going to the ListAttribute definition:</p>
  
  <pre><code>public interface ListAttribute&lt;X extends Object, E extends Object&gt; 
      extends PluralAttribute&lt;X, List&lt;E&gt;, E&gt; {
  </code></pre>
  
  <p>I've tried casting the  <code>criteriaBuilder.isMember(entity, (PluralAttribute)subRoot.get(X_.items))</code> and changing from a Set to a List.</p>
  
  <p>Should this be possible or is there an alternative way to check if an object occurs in a collection in a JPA Criteria query?</p>