title: hibernate criteria - querying tables in n:m relationship
body: <p>I'm trying to build a query with hibernate criteria for the following scenario:</p>
  
  <ul>
  <li>Two entities: Indicator and report (each with their own tables, classes etc.)</li>
  <li>an indicator can be used in zero to many reports</li>
  <li>a report uses zero to many indicators</li>
  <li>therefore, I have an intersection table to store the relationship</li>
  <li>the relationship is defined in both classes and their hibernate mappings</li>
  <li>in the UI, the user can select one or many reports (among other things), and I would like to query the DB for the Indicators used in these reports </li>
  </ul>
  
  <p>I've tried the following:</p>
  
  <pre><code>criteria.add(Restrictions.in("Reports", selectedReports));
  </code></pre>
  
  <p>but all I get is a strange SQL Statement with</p>
  
  <pre><code>where this_.Indicator_ID in (?)
  </code></pre>
  
  <p>and then a JDBC exception (missing parameter)</p>
  
  <p>Any ideas? Thanks.</p>
  
  <p>Note: I've looked into <a href="https://stackoverflow.com/questions/264339/querying-manytomany-relationship-with-hibernate-criteria">Querying ManyToManyrelationship with Hibernate Criteria</a>, but the accepted solution there is to build a custom sql-string ...</p>