title: How to QueryOver using correlated subqueries over an aggregate value?
body: <p>I have the following domain mappings:</p>
  
  <pre><code>Person
  ------
  int PersonId
  IList&lt;PersonDetails&gt; Details;
  
  PersonDetails
  -------------
  Person Owner (mapped by using the FK field, PersonId)
  string Name
  string Address
  DateTime UpdateDate
  </code></pre>
  
  <p>translated to a similiar table structure:</p>
  
  <pre><code>Person
  ------
  PersonId (int)
  Birthday (date)
  
  PersonDetails
  -------------
  PersonId (FK, integer)
  Name (string)
  Address (string)
  UpdateDate (date)
  </code></pre>
  
  <p>How do i recreate the following SQL query using QueryOver?</p>
  
  <pre><code>SELECT * 
  FROM Person p INNER JOIN Details d ON p.PersonId = d.PersonId 
  WHERE d.UpdateDate = (SELECT MAX(UpdateDate) 
                        FROM   PersonDetails
                        WHERE  PersonId = p.PersonId);
  </code></pre>
  
  <p>i.e, select the latest PersonDetails for each Person.
  I've seen examples, but neither of them related to a correlated subquery using an aggregae value...</p>
  
  <p>Thanks,
  Harel</p>