I have a many-to-many relationship between two objects with a join table. I need to be able to select 5 random children based on Parent and date, excluding some children records. I am stuck. Any ideas?
Parent {
static hasMany = [children: Child]
}
Child {
Date dob
static belongsTo = [Parent]
static hasMany = [parents: Parent]
static namedQueries {
randomFiveChildrenBornAfter { parentid, dob, excludeChildren->
qt 'dob', dob
parents {
eq 'id',parentid
}
// not in(excludeChildren) ?? order by rand() ??
}
}
}