0
與圖書和作者域類的國有成員如下:搜索多對一對多的關係
class Book {
static belongsTo = Author
static hasMany = [authors:Author]
String title
}
class Author {
static hasMany = [books:Book]
String name
}
我怎麼會找到這本書由具有標題「的Grails」的作者?
我試過,但它沒有工作(法無簽名:)org.hibernate.collection.PersistentSet.findByTitle(適用於arguemnt類型:(java.lang.String中)值:[Grails的]
Author author = Author.get(1)
def book = author.books.findByTitle("Grails")
這是我需要有小幅調整。我有一個作家實例,所以代碼變成: 作者author = Author.get(1) def b = Book.find(new Book(title:'grails',author:author)) 謝謝! – byamabe 2009-07-24 16:47:14