title: IN clause with a composite primary key in JPA criteria
body: <p>I have a table named <code>group_table</code> in MySQL with only two columns <code>user_group_id</code> and <code>group_id</code> (both of them are of type <code>VARCHAR</code>). Both of these columns together form a composite primary key.</p>
  
  <p>I need to execute a statement using a sub-select <code>IN()</code> to select rows based on a list of values passed to the query.</p>
  
  <pre><code>@Override
  @SuppressWarnings("unchecked")
  public List&lt;GroupTable&gt; getList(List&lt;GroupTable&gt; list)
  {
      CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder();
      CriteriaQuery&lt;GroupTable&gt; criteriaQuery=criteriaBuilder.createQuery(GroupTable.class);
      Root&lt;GroupTable&gt; root = criteriaQuery.from(entityManager.getMetamodel().entity(GroupTable.class));
      criteriaQuery.where(root.in(list));
      return entityManager.createQuery(criteriaQuery).getResultList();
  }
  </code></pre>
  
  <p>The implementation produces the following query.</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT group_id, 
         user_group_id 
  FROM   projectdb.group_table 
  WHERE  ((?, ?) IN ((?, ?), (?, ?))) 
  
  /*Binding parameters.*/
  bind =&gt; [null, null, ROLE_AAA, aaa, ROLE_BBB, aaa]
  </code></pre>
  
  <p>Please notice that the first two parameters which are about the composite key itself are <code>null</code>. They should be <code>user_group_id</code> and <code>group_id</code> respectively.</p>
  
  <p>Why are they not substituted in the parameter list?</p>
  
  <hr>
  
  <p>While I'm not interested in forming a composite primary key in a table, this is (likely) mandatory for JAAS I'm using for authentication.</p>
  
  <p><sub>In this scenario, the query returns the same list as it is supplied from the database which is needless in reality. I actually need this query for deletion of multiple rows.</sub></p>