How to count ocurrences in 1 to many relationship in gorm - grails
- by xain
Hi, I have 2 domain classes
class A {
....
static hasMany = [bs:B]
}
class B {
int code
....
}
How can I list the number of ocurrences of all codes in B in all the A table?
Something like
b.each { thisb ->
int ocurrences = A.bs.findAll{it == thisb}.size()
...
}
Thanks