14. Creating Fetch Plans with Entity Graphs

This chapter explains how to use entity graphs to create fetch plans for Java Persistence API operations and queries.

Entity graphs are templates for a particular Persistence query or operation. They are used when creating fetch plans, or groups of persistent fields that are retrieved at the same time. Application developers use fetch plans to group together related persistent fields to improve runtime performance.

By default, entity fields or properties are fetched lazily. Developers specify fields or properties as part of a fetch plan, and the persistence provider will fetch them eagerly.

For example, an email application that stores messages as EmailMessage entities prioritizes fetching some fields ...

Get The Java EE 7 Tutorial, Volume 2, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.