title: HQL / JPQL - Nested select on FROM
body: <p>I try to convert my SQL query into HQL or JPQL (I want to benefit of the object mapping).</p>
  
  <p>My SQL Request is : </p>
  
  <pre><code>SELECT * 
  FROM (SELECT bde, MAX(creation_date) 
        FROM push_campaign GROUP BY bde) temp, 
  push_campaign pc where pc.bde = temp.bde and pc.creation_date = temp.creation_date;
  </code></pre>
  
  <p>I try (unsuccessfully) to convert it in JPQL with :</p>
  
  <pre><code>select pc 
  from (select bde, max(creationDate) 
        from PushCampaign group by bde) temp, 
  PushCampaign pc 
  where pc.bde = temp.bde and pc.creationDate = temp.creationDate
  </code></pre>
  
  <p>But I got raised : </p>
  
  <blockquote>
  <pre><code>IllegalArgumentException occured :
  </code></pre>
    
    <p>org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near
    line 1, column 16 [select pc from (select id, max(creationDate) from
    models.PushCampaign group by bde) temp, models.PushCampaign pc where
    pc.id = temp.id]</p>
  </blockquote>
  
  <p>I read the nested select can only be in select or where clause.</p>
  
  <p>Do you have workarounds to keep the request and benefit of object-mapping ?</p>