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 over others. The sender, subject, and date will be viewed the most often, in mailbox views and when the message is displayed. The EmailMessage
entity has a collection of related EmailAttachment
entities. For performance reasons the attachments should not be fetched until they are needed, but the file names of the attachment are important. A developer working on this application might make a fetch plan that eagerly fetches the important fields from EmailMessage
and EmailAttachment
while fetching the lower priority data lazily.
The following topics are addressed here:
Table of Contents Java Platform, Enterprise Edition: The Java EE TutorialExpand|
CollapseRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3