title: Hibernate subquery
body: <p>I have a problem in creating subqueries with Hibernate. Unfortunately the Subqueries class is almost entirely undocumented, so I have absolutely no clue how to convert the following SQL into a Hibernate Criteria:</p>
  
  <pre><code>SELECT id
  FROM car_parts
  WHERE car_id IN ( SELECT id FROM cars WHERE owner_id = 123 )
  </code></pre>
  
  <p>I was hoping the following would 'just work':</p>
  
  <pre><code>session.createCriteria(CarParts.class).add(eq("car.owner", myCarOwner));
  </code></pre>
  
  <p>but unfortunately it does not. So it seems I actually have to use the Subqueries class to create the Criteria. But I was unable to find a reasonable example though Google, so that leads me to asking it here.</p>