title: QueryDSL and SubQuery with Tuple condition
body: <p>I am trying to write a query in QueryDSL to fetch the oldest elements of a table grouped by their parentId.</p>
  
  <p>The SQL equivalent should be:</p>
  
  <pre><code>SELECT a.* FROM child a
      INNER JOIN
      (
          SELECT parentId, MAX(revision) FROM child GROUP BY parentId
      ) b
      ON ( 
          a.parentId = b.parentId AND a.revision = b.revision
      )
  </code></pre>
  
  <p>Now in QueryDSL I'm stuck with the syntax.</p>
  
  <pre><code>JPQLQuery&lt;Tuple&gt; subquery = JPAExpressions
                  .select(child.parent, child.revision.max())
                  .from(child)
                  .groupBy(child.parent);
  
  HibernateQuery&lt;Child&gt; query = new HibernateQuery&lt;&gt;(session);
  query.from(child)
      .where(child.parent.eq(subquery.???).and(child.revision.eq(subquery.???))));
  </code></pre>
  
  <p>How do you write this query using a subquery ?</p>
  
  <p><strong>The tables are looking like this :</strong></p>
  
  <pre>___parent___ (not used in this query, but exists)
  parentId
  P1       | *
  P2       | *
  P3       | *
  
  ___child___
  parentId | revision
  P1       | 1       | *
  P1       | 2       | *
  P1       | 3       | *
  P2       | 2       | *
  P2       | 3       | *
  P3       | 1       | *
  
  ___result from child, the highest revision for each parentId___
  P1       | 3       | *
  P2       | 3       | *
  P3       | 1       | *</pre>
  
  <p><strong>What I've tried so far :</strong></p>
  
  <pre><code>.where(JPAExpressions.select(child.parent,child.revision).eq(subquery));
  
  -&gt; org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected end of subtree
  </code></pre>
  
  <p>and many syntax errors ...</p>
  
  <p>I use a dirty loop, for now, since I haven't found a solution yet.</p>