| If you have an EAGER collection, the collection will be fetched using a JOIN between the parent entity table and the child entity one. That's how EAGER works. If the collection is set a LAZY (default), the collection is going to be initialized with a secondary select upon being accessed for the first time. Entity graphs follow the same principles. If the collection is LAZY and you omit to include it in an Entity Graph, then the collection is going to be loaded lazily. If you include it in the EntityGraph, it will be loaded EAGERLY, with a JOIN. That's how collections are fetched. Now, related to pagination, Hibernate will always fetch the whole collection and paginate the root entities into memory. You cannot change that. However, you don;t have to fetch root entities with pagination. You can use two queries instead: 1. First, you fetch the root entity identifiers for the current page 2. You fetch the child entities just for the current root entity identifiers Associations are not as flexible as queries when it comes to pagination. I wrote a whole chapter about this topic in my book, High-Performance Java Persistence. |