title: HQL Inner join on same table
body: <p>I asked an earlier question today which was about GORM: <a href="https://stackoverflow.com/questions/14484883/how-to-fetch-records-in-grails-by-max-date-and-group-at-same-time">How to fetch records in grails by max date and group at same time</a>  However, someone suggested it can be easily achieved using HQL. But using HQL I'm getting <code>unexpected token</code> error. When I researched this I found out that HQL doesn't allow <code>INNER JOINS</code> unless there is an association between two entities: <a href="https://stackoverflow.com/questions/11741439/hql-left-join-on-the-same-table">HQL, left join on the same table</a></p>
  
  <p>So, I'm lost. To begin with, I'm frustrated why such a simple query isn't supported by GORM and now with HQL my question is: How do I perform an INNER JOIN on a subset? </p>
  
  <p>What I've tried:</p>
  
  <blockquote>
    <p>unexpected token: ( near line 1, column 16 [ select c from ( select
    name, max(dateCreated) as maxTime from com.mine.Color
    group by name ) as t inner join Color c on c.name = t.name and
    c.dateCreated = t.maxTime ]</p>
  </blockquote>
  
  <p>I suspected that the second instance of <code>Color</code> was not being detected since the package name didn't get automatically prefixed to it. So reading other answers I tried:</p>
  
  <blockquote>
    <p>unexpected token: ( near line 1, column 16 [ select c from ( select
    name, max(dateCreated) as maxTime from com.mine.Color
    group by name ) as t , com.mine.Color as c on c.name =
    t.name and c.dateCreated = t.maxTime ]</p>
  </blockquote>