I have 3 domain classes:
class Contract {
String referenceNumber
static belongsTo = [subCategory:SubCategory]
}
class SubCategory {
String name
static belongsTo = [category:Category]
static hasMany = [contracts:Contract]
}
class Category {
String name
static hasMany = [subCategories:SubCategory]
}
I want to find all contracts which belong to the given category (so get all sub categories for the given category and then get all the contracts for all these sub categories). This is what I tried:
Contract.findAllBySubCategory(SubCategory.findAllByCategory(Category.get(1)))
but it keeps giving me an error:
groovy.lang.MissingMethodException: No signature of method:
Contract.findAllBySubCategory() is applicable for argument types:
(java.util.ArrayList) values: [[SubCat01, SubCat02, SubCat03]]
Possible solutions: findAllBySubCategory(java.util.List)
Does anyone know what I’m doing wrong?
The
findAlldynamic finder returns a list but expects a scalar parameter by default. Try using theInListcomparator.