Grails - hasMany has too many, need to limit get() results in Oracle
When you load the Publisher, the books don't get loaded until you access the books
collection - it's lazily loaded on-demand for exactly this reason. If you want to retrieve a few of the Publisher's books, use a query, e.g.
def publisherInstance = Publisher.get(params.id)int offset = ...def books = Book.findAllByPublisher(publisherInstance, [max: 10, offset: offset])
and to select the correct page, calculate offset
from the pagination parameters.
Instead of the dynamic finder, in general case you can use criteria:
class Book { static belongsTo = [publisher: Publisher]}
And to get the list of 10 first books of publisher "2"
offset = 0// Get books of publisherdef queryResult = Book.createCriteria().list(max: 10, offset: offset) { publisher { eq("id", 2) } }