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


batch

Use eclipselink.batch to supply EclipseLink with batching information so subsequent queries of related objects can be optimized in batches, instead of being retrieved one-by-one or in one large joined read.


Values

This query hint accepts a single-valued, relationship path expression.


Usage

Using the eclipselink.batch hint is more efficient than joining, because EclipseLink avoids reading duplicate data.

You can only batch queries that have a single object in the select clause.

Valid values: a single-valued relationship path expression.


NoteNote:

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



Examples

Example 4-1 shows how to use this hint in a JPA query.

Example 4-1 Using batch in a JPA Query

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 query.setHint("eclipselink.batch", "e.address");

Example 4-2 shows how to use this hint with the @QueryHint annotation.

Example 4-2 Using batch in a @QueryHint Annotation

import org.eclipse.persistence.config.HintValues;
 import org.eclipse.persistence.config.QueryHints;
 @QueryHint(name=QueryHints.BATCH, value="e.address");


See Also

For more information, see: