Use eclipselink.join-fetch hint to join attributes in a query.
Note:
Use dot notation to access nested attributes. For example, to batch-read an employee's manager's address, use e.manager.address.
Table 4-21 describes this query hint's valid values.
This hint is similar to eclipselink.batch. Subsequent queries of related objects can be optimized in batches instead of being retrieved in one large joined read
The eclipselink.join-fetch hint differs from JPQL joining in that it allows multilevel fetch joins.
Example 4-42 shows how to use this hint in a JPA query.
Example 4-42 Using join-fetch in a JPA Query
import org.eclipse.persistence.config.HintValues;
import org.eclipse.persistence.config.QueryHints;
query.setHint("eclipselink.join-fetch", "e.address");
Example 4-43 shows how to use this hint with the @QueryHint annotation.
Example 4-43 Using join-fetch in a @QueryHint Annotation
import org.eclipse.persistence.config.HintValues; import org.eclipse.persistence.config.QueryHints; @QueryHint(name=QueryHints.FETCH, value="e.address");
For more information, see:
"Optimizing Queries" in Understanding Oracle TopLink.
"Fetch Joins" in the JPA Specification (http://jcp.org/en/jsr/detail?id=317)
"Enhancing Performance" in Solutions Guide for Oracle TopLink