Grails 搜索多对多关系的所有成员

Grails 搜索多对多关系的所有成员,grails,has-many,Grails,Has Many,使用Book和Author域类,如下所示: class Book { static belongsTo = Author static hasMany = [authors:Author] String title } class Author { static hasMany = [books:Book] String name } 我怎样才能找到一位名为“圣杯”的作者写的书呢 我尝试了这个方法,但没有成功(没有方法的签名:org.hibernate.

使用Book和Author域类,如下所示:

class Book { 
    static belongsTo = Author
    static hasMany = [authors:Author]
    String title
}

class Author {
   static hasMany = [books:Book]
   String name
}
我怎样才能找到一位名为“圣杯”的作者写的书呢

我尝试了这个方法,但没有成功(没有方法的签名:org.hibernate.collection.PersistentSet.findbyttle()适用于arguemnt类型:(java.lang.String)value:[Grails]

Author author = Author.get(1)
def book = author.books.findByTitle("Grails")

您可以通过以下示例进行搜索

Author author = Author.get(1) def b = Book.find( new Book(title:'grails', author:author) ) Author=Author.get(1)def b=Book.find(新书(标题:'grails',作者:Author))
有关如何进行查询的信息,请参阅。

这是我需要的,只是做了一点小小的修改。我有一个author实例,因此代码变成:author author=author.get(1)def b=Book.find(新书(标题:'grails',author:author)),谢谢!