Have the following problem: I have Bookmaker and Users domain classes. And one Bookmaker has many Users.
class Bookmaker {
...
static hasMany = [users: User ...]
...
}
And User domain class doesn't contain reference to Bookmaker. My goal is to create method that will return Bookmaker that owns particular User. It looks like:
def lookupBookmaker() {
User user = User.get(springSecurityService.principal.id)
def query = Bookmaker.where {
users.contains(user)
}
Bookmaker bookmaker = query.find()
bookmaker
}
but it doesn't work and gives the following exception:
Class groovy.lang.MissingMethodException Message No signature of method: grails.gorm.DetachedCriteria.contains() is applicable for argument types: (cmscore.User) values: [cmscore.User : 2] Possible solutions: toString(), toString(), notify(), combinations()
and it says that wrong code is this:
users.contains(user)
What I'm doing wrong? Thanks!