I am trying to query the following HQL using GORM:
MailMessage.executeQuery("toId, count(toId) from (SELECT toId, threadId FROM MailMessage as m WHERE receiveStatus = 'u' GROUP BY threadId, toId) as x group by x.toId")
java.lang.IllegalArgumentException: node to traverse cannot be null!
I am answering my own question. The only way to do this is to execute raw SQL and not use HQL. Unfortunately, there is no way that I figured out how to execute a complicated query with a subquery and computed field.
I used the example here: Grails query not using GORM