public class Document extends Model { ... @ManyToMany public Set accessors; ... }
I want to select all Documents which accessors conta
SELECT d FROM Document AS d WHERE :user MEMBER OF d.accessors
Should be what you need, and it is simpler than joining tables. Just dont forget to use the user as a parameter instead of using its id:
query.setParameter("user", user);