title: How to query for all entries a WHERE "b MEMBER OF a.list"
body: <p>I have an entity, let's say A, which has a field that is a list of another entity, let's say B.</p>
  
  <p>This is A:</p>
  
  <pre><code>@Entity
  @Table(name = "a")
  public class A implements Serializable{
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
      @SequenceGenerator(name = "sequenceGenerator")
      private Long id;
  
      @ManyToMany
      @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
      @JoinTable(name = "a_b",
                 joinColumns = @JoinColumn(name="as_id", referencedColumnName="id"),
                 inverseJoinColumns = @JoinColumn(name="bs_id", referencedColumnName="id"))
      private Set&lt;B&gt; bs = new HashSet&lt;&gt;();
  }
  </code></pre>
  
  <p>This is B:</p>
  
  <pre><code>@Entity
  @Table(name = "b")
  public class B implements Serializable{
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
      @SequenceGenerator(name = "sequenceGenerator")
      private Long id;
  
      @NotNull
      @Column(name = "name", nullable = false)
      private String name;
  
      @Column(name = "description")
      private String description;
  }
  </code></pre>
  
  <p>Now, what I'm trying to achieve is to be able to query for all the entries a of A, having an entity b of B in a.bs</p>
  
  <p>Tha actual query is show below:</p>
  
  <pre><code>@Repository
  public interface ARepository extends JpaRepository&lt;A, Long&gt; {
      @Query("SELECT DISTINCT a FROM A a LEFT JOIN FETCH a.bs bs WHERE :b MEMBER OF bs")
      List&lt;A&gt; findAllByB(@Param("b") B b);
  }
  </code></pre>
  
  <p>Wasn't it supposed to work like this?</p>
  
  <p>However the error I get is the one below, I put it on pastebin due to exceeding the size limits of the post:</p>
  
  <p><a href="https://pastebin.com/yH74ijn7" rel="nofollow noreferrer">Log</a></p>