Chapter 12. Fetch plans, strategies, and profiles

 

In this chapter

  • Lazy and eager loading
  • Fetch plans, strategies, and profiles
  • Optimizing SQL execution

In this chapter, we explore Hibernate’s solution for the fundamental ORM problem of navigation, as mentioned in section 1.2.5. We show you how to retrieve data from the database and how you can optimize this loading.

Hibernate provides the following ways to get data out of the database and into memory:

12.1. Lazy and eager loading

12.1.1. Understanding entity proxies

12.1.2. Lazy persistent collections

12.1.3. Lazy loading with interception

12.1.4. Eager loading of associations and collections

12.2. Selecting a fetch strategy

12.2.1. The n+1 selects problem

12.2.2. The Cartesian product problem

12.2.3. Prefetching data in batches

12.2.4. Prefetching collections with subselects

12.2.5. Eager fetching with multiple SELECTs

12.2.6. Dynamic eager fetching

12.3. Using fetch profiles

12.3.1. Declaring Hibernate fetch profiles

12.3.2. Working with entity graphs

12.4. Summary

sitemap