1
假設你有三個域OBJ文件定義爲這樣:GORM「其中標準」多很多-to-many關聯
class Author {
String name
static hasMany = [books: Book]
}
class Book {
String name
static belongsTo = [author: Author]
static hasMany = [words: Word]
}
class Word {
String text
Set<Author> getAuthors() {
// This throws GenericJDBCException:
Author.where {
books.words == this
}
}
}
爲什麼getAuthors()
失敗,ERROR spi.SqlExceptionHelper - Parameter "#1" is not set;
但工作正常,如果使用Criteria
改寫:
public Set<Author> getAuthors() {
// This works as expected:
Author.withCriteria {
books {
words {
eq('id', this.id)
}
}
}
}
我有'where查詢'的語法錯誤嗎?
我的印象是比較藏品的實體時,有一個隱含的傳播操作。感謝澄清。 – mdlandon