Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/UserGuide/JPA/2.4/a batchfetch


Java Persistence API (JPA) Extensions Reference for EclipseLink, 2.4.x

SearchSearch

   Contents Contents


Previous Previous

Next Next

WarningBeta Draft: 2012-06-18


@BatchFetch

Use @BatchFetch to read objects related to a relationship mapping (such as one-to-one, one-to-many, many-to-one, many-to-many, and element collection) to be read in a single query.

Annotation Elements

Table 2-3 describes this annotation's elements.

Table 2-3 @BatchFetch Annotation Elements

Annotation Element Description Default

size

Default size of the batch fetch, used only when BatchFetchType=IN to definite number of keys in each IN clause

256 or the query's pageSize (for cursor queries)

BatchFetchType

(optional) The type of batch fetch to use:

  • JOIN
  • EXISTS
  • IN

JOIN


Usage

Batch fetching allows for the optimal loading of a tree. Setting the @BatchFetch annotation on a child relationship of a tree structure causes EclipseLink to use a single SQL statement for each level.

Examples

The following examples show how to use this annotation with different batch fetch types.

Example 2-7 Using JOIN BatchFetch Type



Example 2-8 Using EXISTS BatchFetch Type



Example 2-9 Using IN BatchFetch Type



See Also

For more information, see:

 


Previous Previous

Next Next

EclispeLink
EclipseLink logo EclipseLink Home • PDF PDF (coming soon)

SearchSearch

   Contents Contents

Back to the top