0

Consider the first query:

def books =  Book.withCriteria {
   eq("category", "fiction")
}

How can I use the result of this query in the next query to get all the authors who wrote these books?

I tried:

def authors = Author.withCriteria {
  'in'("books", books)
}

but this is not working. What can I do to fix it?

Michael
  • 32,527
  • 49
  • 210
  • 370

1 Answers1

1

Can't you just query the association directly?

def authors = Author.withCriteria {
  books {
    eq("category", "fiction")
  }
}
Ian Roberts
  • 120,891
  • 16
  • 170
  • 183