Grails groupProperty and order. How it works?

2019-05-07 13:41发布

I have this domain :

class Participation {
   ParticipationStatus status
}
class ParticipationStatus{
   String name
   Date creationDate
}

I create a query :

Participation.createCriteria().list{
   createAlias("status","statusAlias")
   order "statusAlias.creationDate"
   projections{
     groupProperty "id"    
   }
}

But I received an error : Caused by: java.sql.SQLException: ORA-00979: N'est pas une expression GROUP BY

I 'm working 2 days ago on this query grrrr ! ;-)

Thanks a lot

1条回答
Explosion°爆炸
2楼-- · 2019-05-07 14:03

Every field you use in aggregate queries (the one using projections) should be either a groupProperty, or only an aggregate function argument (that is, in projections anyway). In this example, try

Participation.createCriteria().list{
   createAlias("status","statusAlias")
   order "statusAlias.creationDate"
   projections{
     groupProperty "id"    
     groupProperty "statusAlias.creationDate"
   }
}
查看更多
登录 后发表回答