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