模型:
class Author{
String name
static hasMany = [books: Book]
}
class Book{
String name
Author author
static belongsTo = Author
}
然后我有一个控制器
class MyController{
def authors{
def authors = Author.getAll()
render authors as JSON
}
问题在于,即使 Author-Books 关联是惰性的,也会执行 N+1 个查询以急切地获取每个 Author 的书籍。它会发生什么,我该如何禁用它