I have two classes
Quiz{
String name
static hasMany[tags:Tag]
}
Tag{
String tag
}
How can I write the following query in grails using criteria builder
select count(tag_id),tag from quiz_tag
left outer join tag on tag_id=id
group by tag_id,tag
You could do this with a criteria query if you map the many-to-many table with a domain class, like explained here.
The
countsvariable will be aListof[Tag object, count of the Tag]lists.