Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.5
  Go To Table Of Contents
 Search
 PDFComments
Comments


join-fetch

Use eclipselink.join-fetch hint to join attributes in a query.


NoteNote:

Use dot notation to access nested attributes. For example, to batch-read an employee's manager's address, use e.manager.address.



Values

Table 4-21 describes this query hint's valid values.

Table 4-21 Valid Values for eclipselink.join-fetch hint

Value

A relationship path expression



Usage

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.


Examples

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");


See Also

For more information, see: