title: JPQL Query With Twice MEMBER OF And Selection Before
body: <p>I have two User entities u1 and u2
  Which have a WorkspaceMember relation by WorkspaceMember.user -> user
  And a Workspace entity which contains Workspace.members -> [WorkspaceMember...]</p>
  
  <p>Now what I'm trying to create is a JPQL query which firsts finds two WorkspaceMember entities by their User property and then finding the Workspaces that contain both WorkspaceMember entites.</p>
  
  <p>Here is my query so far which is not working at all - I hope someone can help me on this one as i have not found any suitable example.</p>
  
  <p>String sql = "SELECT wm1 FROM WorkspaceMember wm1 WHERE wm1.user = :user1 AND " +
                  "SELECT wm2 FROM WorkspaceMember wm2 WHERE wm2.user = :user2 AND EXISTS " +
                  "(SELECT ws1 FROM Workspace ws1 WHERE (wm1 MEMBER OF ws1.members) AND (wm2r MEMBER OF ws1.members))";</p>
  
  <p>Seconf approach also not working:</p>
  
  <p>String sql2 = "SELECT ws FROM Workspace ws WHERE EXISTS (SELECT wm1 FROM WorkspaceMember wm1 WHERE wm1.user = :user1 AND wm1 MEMBER OF ws.members) AND (SELECT wm2 FROM WorkspaceMember wm2 WHERE wm2.user = :user2 AND wm2 MEMBER OF ws.members)";
  Thanks,</p>
  
  <p>Gerrit</p>