Eager loading
Eager loading is a data-loading strategy that retrieves required data before it is requested individually, often fetching related data together with its primary entity.
Java Persistence with Spring Data and Hibernate epub
Eager loading is a persistence technique that retrieves associated data together with the owning entity rather than deferring access.
- How it is used
- Uses eager loading to make associations available with an entity, including after detachment, while balancing retrieval costs.
- How deep it goes
- Explains mapping, generated joins and SELECTs, detached access, fetch-depth configuration, performance tradeoffs, and merge behavior.
- Examples
- Uses an Item with a seller, bids, and images to illustrate detached access, joined results, and separate SELECTs.
- What you can do after
- Apply it via Hibernate mappings and per-procedure fetch strategies while assessing query count, result size, and detached access.
Read how Java Persistence with Spring Data and Hibernate epub explains eager loading →
.NET in Action, Second Edition
Eager loading retrieves an entity and specified related entities as part of the same query operation.
- How it is used
- Retrieves related entities alongside primary entities when a query needs the complete object graph immediately.
- How deep it goes
- Explains Include, multiple relationships, and query trade-offs, but defers explicit and select loading.
- Examples
- Demonstrates loading Books with Ratings and printing each rating’s stars and comment.
- What you can do after
- Apply it via Entity Framework Core by adding Include expressions to relationship queries.
Read how .NET in Action, Second Edition explains eager loading →
Related concepts
- lazy initializationcontrasts with · Lazy initialization is a technique that postpones creating, retrieving, computing, or loading a value or resource until it is needed.
- FetchType.EAGERconfigured by · FetchType.EAGER is a Jakarta Persistence fetch option specifying that an associated value is retrieved with its owning entity.
- N + 1 query problemaddresses · The N+1 query problem is an inefficient data-access pattern in which one query retrieves a collection and a separate additional query retrieves related data for each item.
- Cartesian productcontrasts with · The Cartesian product of sets is the set of ordered tuples formed by choosing one element from each set.
- fetch profileconfigured by · A fetch profile is a Hibernate-defined loading configuration that selectively overrides association and collection fetching for a unit of work.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

