我有這個的Grails 2.0.3項目,其中有兩種型號DomainA
和DomainB
無一不是由many-to-many
關係,其中DomainB
是相互關聯的一個孩子DomainA
。的Grails的hasMany:找到孩子一個匹配條件的所有主數據記錄
class DomainA {
// properties
static hasMany = [domains: DomainB]
}
class DomainB {
// properties
static hasMany = [domains: DomainA]
static belongsTo = [DomainA]
}
由於這種設計,我想查詢所有DomainB
,其中有/設置爲DomainA
查詢以下的的DomainA
實例(S)。
def domainsList = DomainA.createCriteria().list() {
// other criterions for the other properties
}
DomainB.createCriteria().list() {
inList("domains", domainsList)
// other criterions for the other properties
}
當執行上面的代碼,錯誤是提示ERROR util.JDBCExceptionReporter - Parameter #1 has not been set.
其中Parameter #1
是提示在inList
準則的domains
屬性名稱。
有這個問題,這是可以解決的嗎?怎麼樣?
你有類'DomainA'定義了兩次。你能解決你的問題嗎? – ubiquibacon 2012-08-02 04:23:55
已更新。感謝您的通知。 – 2012-08-02 04:49:02
我認爲'inList'可能不是正確的謂詞:B.domains是一個列表,而不是一個DomainA,所以它永遠不會是由DomainAs組成的列表的成員,對吧? – 2012-08-02 04:54:08