0
class Store {
String name
static hasMany = [departments: Department]
}
class Department {
String name
static belongsTo = [store: Store]
static hasMany = [products: Product]
}
class Product {
String name
Integer qty
static namedQueries = {
productsInStockByStore {store->
department {
store {
eq 'id', store.id
}
}
gt 'qty', 0
}
}
static belongsTo = [department: Department]
}
我得到一个错误的运行:
def store = Store.first() // just for the sake of testing
Product.productsInStockByStore(store).list()
法无签名:namedboom.Store.call()适用对于 参数类型: (namedboom.Product $ __ clinit__closure1 $ _closure3 $ _closure4 $ _closure5) values: [namedboom.Product $ __ clinit__closure1 $ _closure3 $ _closure4 $ _clos ure5 @ 768aab6a] 可能的解决方案:等待(),最后(),保存(),任(),GETALL(), 等待(长)
什么是与名为做到这一点的正确方法查询?我可以使用它的唯一方法是使用createCriteria并为父表声明关节。
在这种情况下,会出现另一个问题。为什么一小时前我不问这个? ..尴尬..谢谢! – Micor