title: Is calling elements(?) on a selected set possible?
body: <p>I have two entities which they have a many-to-many relationship. E.g. AEnt and BEnt:<br></p>
  
  <pre><code>class AEnt {
      //....
      String name;
      Set&lt;BEnt&gt; bs;
   }
  
  class BEnt {
      //....
   }
  </code></pre>
  
  <p>I want to select such BEnts where the names of their AEnts are like "somthing". My query now is like this:<br></p>
  
  <pre><code>from BEnt b where b in 
       (select elements(a.bs) from AEnt a where a.name like :name)
  </code></pre>
  
  <p>But the problem is Hibernate at first calls elements on all AEnts-BEnts and in fact ignores my "like" filter. Because I have millions of AEnt-BEnt relations, the query becomes not responding. Is there a way to call elements just on the selected set of AEnts? Or a better query?<br> Thanks.</p>