I'm trying to create GORM criteria query filtering by a property of sub-entity. So there are such entities:
class PaymentEntry {
static hasOne = [category: PaymentCategory]
static constraints = {
category(nullable: true)
}
// other stuff
}
class PaymentCategory {
static hasMany = [payments: PaymentEntry]
// other stuff
}
Now I'm trying to select PaymentEntries, with specific categories. I was trying something like this:
def c = PaymentEntry.createCriteria()
def res = c {
'in'("category", categories)
}
categories here is a list of PaymentCategory entities, selected earlier.
Unfortunately, this fails. Grails throws NoSuchMethodException.