title: Composite Key with IN clause
body: <p>Below piece of code is supposed to return list of entities for which the primarykeys(idList) match in DB.</p>
  
  <p>This works fine for primitive Id types, but for composite keys, it does not. please help me. </p>
  
  <pre><code>Class&lt;?&gt; entityType = TypeToken.of(typeOfEntity).getRawType();
  Class&lt;?&gt; idType = TypeToken.of(typeOfId).getRawType();
  
  String idFieldName = getIdFieldName(entityManager, entityType, idType);
  
  CriteriaQuery&lt;?&gt; criteria = entityManager.getCriteriaBuilder().createQuery(entityType);
  Root&lt;?&gt; root = criteria.from(entityType);
  Expression&lt;ID&gt; expression = root.get(idFieldName);
  Predicate predicate = expression.in(idList);
  
  TypedQuery&lt;?&gt; query = entityManager.createQuery(criteria.where(predicate));
  return (List&lt;T&gt;) query.getResultList();
  </code></pre>
  
  <p>I am using Hibernate now, and when i run the test i got the following sql from hibernate logs.</p>
  
  <p>select * from paper_invoice paperinvoi0_  where paperinvoi0_.paymentid=? and paperinvoi0_.receipt_code=? and paperinvoi0_.usetype=?</p>
  
  <p>This looks fine, but it throws an exception:
   javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query.</p>
  
  <p>I am not sure whats the issue here. can anyone point out ?</p>