Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails groupProperty and order. How it works?

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

like image 785
Jonathan Lebrun Avatar asked Mar 07 '11 13:03

Jonathan Lebrun


1 Answers

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"
   }
}
like image 64
Victor Sergienko Avatar answered Nov 04 '22 05:11

Victor Sergienko