title: jpa criteria for many to many relationship
body: <p>I have 2 POJO classes in Java, Answer and Collaborator, in a many-to-many relationship.</p>
  
  <pre><code>class Answer {
      @ManyToMany(cascade = CascadeType.ALL)
      @JoinTable(name = "ANSWERS_COLLABORATORS", joinColumns = { @JoinColumn(name = "aid") }, inverseJoinColumns = { @JoinColumn(name = "cid") })
      private Set&lt;Collaborator&gt; collaborators = new HashSet&lt;Collaborator&gt;(0);
  } 
  </code></pre>
  
  <p>Class <code>Answer</code> has a set of <code>Collaborator</code>, but a <code>Collaborator</code> doesn't keep a set of <code>Answer</code>.
  What I need to do from Hibernate <code>CriteriaQuery</code> is to find the collaborators for an answer given by id.</p>
  
  <p>I have already done this with Hibernate <code>Criteria</code> (<code>org.hibernate.Criteria</code>) using result transformer, but I'm stuck when it comes to using <code>CriteriaQuery</code>, because I don't have a list of answers to give to the join.</p>