title: Selecting generic primary key with CriteriaQuery
body: <p>When migrating from Hibernate Criteria api to CriteriaQuery I ran into a generic DAO for a abstract class that has a where on a common field but does a select on their id, even if the ids are totally different per class.</p>
  
  <p>The old projection looks like this</p>
  
  <pre><code>criteria.setProjection(Projections.id());
  </code></pre>
  
  <p>Is there any way to do this in a similar way with CriteriaQuery?</p>
  
  <p>Edit: Full criteria code</p>
  
  <pre><code>DetachedCriteria detachedCriteria = DetachedCriteria.forClass(MyEntity.class);
  detachedCriteria.add(Restrictions.in("accountID", accounts));
  detachedCriteria.setProjection(Projections.id());
  
  EntityManager em = ...;
  Criteria criteria = detachedCriteria.getExecutableCriteria((Session) em.getDelegate());
  List&lt;Integer&gt; list = criteria.list();
  </code></pre>