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

Difference between revisions of "EclipseLink/UserGuide/JPA/2.4/a batchfetch"

m
Line 4: Line 4:
 
|category=JPA
 
|category=JPA
 
|release=2.4.x
 
|release=2.4.x
|title= }}
+
|title=TLJPA }}
 
<span class="metaname">    </span>
 
<span class="metaname">    </span>
  
 
{| class="simple oac_no_warn" width="100%"
 
{| class="simple oac_no_warn" width="100%"
 
| align="left" valign="top" |   
 
| align="left" valign="top" |   
| width="144" align="right" valign="bottom" |
+
| width="185" align="right" valign="bottom" |
 
{| class="simple oac_no_warn" width="100%"
 
{| class="simple oac_no_warn" width="100%"
 
|
 
|
 
| align="center" valign="top" |
 
| align="center" valign="top" |
[http://www.google.com/cse/home?cx=016171230611334810008:y5kxq4rqd8s&hl=en Search]
+
[[Image:Elug_Magnifier.png|Search]][http://www.google.com/cse/home?cx=016171230611334810008:y5kxq4rqd8s&hl=en Search]
 
| align="center" valign="top" |
 
| align="center" valign="top" |
[[EclipseLink/UserGuide/JPA/toc| Contents]]
+
&nbsp;&nbsp;&nbsp;[[Image:Elug_guide_icon.png|Contents]][[EclipseLink/UserGuide/JPA/2.4/toc| Contents]]
 
|}
 
|}
 
|}
 
|}
Line 21: Line 21:
 
----
 
----
  
{| width="150"
+
{| width="165"
 
| align="center" |
 
| align="center" |
[[EclipseLink/UserGuide/JPA/a_array|&lt;- Previous]]
+
[[EclipseLink/UserGuide/JPA/2.4/a_array| Previous ]]<span class="previouslink">[[Image:Elug_previous_icon.png|Previous]]</span>
 
| align="center" |
 
| align="center" |
[[EclipseLink/UserGuide/JPA/a_cache|Next -&gt;]]
+
[[EclipseLink/UserGuide/JPA/2.4/a_cache| Next ]][[Image:Elug_next_icon.png|Next]]
 
|
 
|
 
|}
 
|}
 +
 +
[[Image:Elug_draft_icon.png|Warning]]Beta Draft: 2012-06-18
  
 
<span id="CHDCCIDA"></span>
 
<span id="CHDCCIDA"></span>
Line 37: Line 39:
 
Use <code>@BatchFetch</code> 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.
 
Use <code>@BatchFetch</code> 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.
  
<span id="sthref27"></span>
+
<span id="sthref25"></span>
  
 
''' '''
 
''' '''
Line 43: Line 45:
 
===Annotation Elements===
 
===Annotation Elements===
  
[[#CHDJBJBC|Table 2-1]] describes this annotation's elements.
+
[[#CHDJBJBC|Table 2-3]] describes this annotation's elements.
  
<span id="sthref28"></span><span id="CHDJBJBC"></span>
+
<span id="sthref26"></span><span id="CHDJBJBC"></span>
  
'''''Table 2-1 @BatchFetch Annotation Elements'''''
+
'''''Table 2-3 @BatchFetch Annotation Elements'''''
  
 
{| class="HRuleFormalWide" dir="ltr" title="@BatchFetch Annotation Elements" summary="This table describes the list of attributes for this annotation." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
 
{| class="HRuleFormalWide" dir="ltr" title="@BatchFetch Annotation Elements" summary="This table describes the list of attributes for this annotation." width="100%" border="1" frame="hsides" rules="rows" cellpadding="3" frame="hsides" rules="rows"
 
|- align="left" valign="top"
 
|- align="left" valign="top"
! id="r1c1-t2" align="left" valign="bottom" | '''Annotation Element'''
+
! id="r1c1-t6" align="left" valign="bottom" | '''Annotation Element'''
! id="r1c2-t2" align="left" valign="bottom" | '''Description'''
+
! id="r1c2-t6" align="left" valign="bottom" | '''Description'''
! id="r1c3-t2" align="left" valign="bottom" | '''Default'''
+
! id="r1c3-t6" align="left" valign="bottom" | '''Default'''
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r2c1-t2" headers="r1c1-t2" align="left" |
+
| id="r2c1-t6" headers="r1c1-t6" align="left" |
 
size
 
size
| headers="r2c1-t2 r1c2-t2" align="left" |
+
| headers="r2c1-t6 r1c2-t6" align="left" |
 
Default size of the batch fetch, used only when <code>BatchFetchType</code>=<code>IN</code> to definite number of keys in each <code>IN</code> clause
 
Default size of the batch fetch, used only when <code>BatchFetchType</code>=<code>IN</code> to definite number of keys in each <code>IN</code> clause
| headers="r2c1-t2 r1c3-t2" align="left" |
+
| headers="r2c1-t6 r1c3-t6" align="left" |
 
<code>256</code> or the query's <code>pageSize</code> (for cursor queries)
 
<code>256</code> or the query's <code>pageSize</code> (for cursor queries)
 
|- align="left" valign="top"
 
|- align="left" valign="top"
| id="r3c1-t2" headers="r1c1-t2" align="left" |
+
| id="r3c1-t6" headers="r1c1-t6" align="left" |
 
BatchFetchType
 
BatchFetchType
| headers="r3c1-t2 r1c2-t2" align="left" |
+
| headers="r3c1-t6 r1c2-t6" align="left" |
 
(optional) The type of batch fetch to use:
 
(optional) The type of batch fetch to use:
  
Line 70: Line 72:
 
* EXISTS
 
* EXISTS
 
* IN
 
* IN
| headers="r3c1-t2 r1c3-t2" align="left" |
+
| headers="r3c1-t6 r1c3-t6" align="left" |
 
JOIN
 
JOIN
 
|}
 
|}
Line 76: Line 78:
 
<br />
 
<br />
  
<span id="sthref29"></span>
+
<span id="sthref27"></span>
  
 
''' '''
 
''' '''
Line 84: Line 86:
 
Batch fetching allows for the optimal loading of a tree. Setting the <code>@BatchFetch</code> annotation on a ''child'' relationship of a tree structure causes EclipseLink to use a ''single'' SQL statement for each level.
 
Batch fetching allows for the optimal loading of a tree. Setting the <code>@BatchFetch</code> annotation on a ''child'' relationship of a tree structure causes EclipseLink to use a ''single'' SQL statement for each level.
  
<span id="sthref30"></span>
+
<span id="sthref28"></span>
  
 
''' '''
 
''' '''
Line 90: Line 92:
 
===Examples===
 
===Examples===
  
Para.
+
The following examples show how to use this annotation with different batch fetch types.
  
<span id="sthref31"></span>
+
<span id="sthref29"></span>
  
'''''Example 2-1 Using JOIN BatchFetch Type'''''
+
'''''Example 2-7 Using JOIN BatchFetch Type'''''
  
 +
 +
 
   
 
   
  
<span id="sthref32"></span>
+
<span id="sthref30"></span>
  
'''''Example 2-2 Using EXISTS BatchFetch Type'''''
+
'''''Example 2-8 Using EXISTS BatchFetch Type'''''
  
 +
 +
 
   
 
   
  
<span id="sthref33"></span>
+
<span id="sthref31"></span>
  
'''''Example 2-3 Using IN BatchFetch Type'''''
+
'''''Example 2-9 Using IN BatchFetch Type'''''
  
 +
 +
 
   
 
   
  
<span id="sthref34"></span>
+
<span id="sthref32"></span>
  
 
''' '''
 
''' '''
Line 118: Line 126:
 
For more information, see:
 
For more information, see:
  
* [[EclipseLink/UserGuide/JPA/a_joinfetch|"@JoinFetch"]]
+
* [[EclipseLink/UserGuide/JPA/2.4/a_joinfetch|"@JoinFetch"]]
 +
 
 +
<span id="footerspace"> </span>
  
 
----
 
----
Line 125: Line 135:
 
|-
 
|-
 
| valign="bottom" |
 
| valign="bottom" |
{| width="150"
+
{| width="165"
 
|-
 
|-
 
|
 
|
 
| align="center" |
 
| align="center" |
[[EclipseLink/UserGuide/JPA/a_array|&lt;- Previous]]
+
[[EclipseLink/UserGuide/JPA/2.4/a_array| Previous ]]<span class="previouslink">[[Image:Elug_previous_icon.png|Previous]]</span>
 
| align="center" |
 
| align="center" |
[[EclipseLink/UserGuide/JPA/a_cache|Next -&gt;]]
+
[[EclipseLink/UserGuide/JPA/2.4/a_cache| Next ]][[Image:Elug_next_icon.png|Next]]
 
|}
 
|}
 
| width="34%" align="center" |
 
| width="34%" align="center" |
[[Image:Eclipselink-logo.gif|150px|EclispeLink]]<br />[http://wiki.eclipse.org/EclipseLink EclipseLink Home]<br />
+
[[Image:Eclipselink-logo.gif|150px|EclispeLink]]<br />[[Image:Elug_home_icon.png|EclipseLink logo]] [http://www.eclipse.org/eclipselink/ EclipseLink Home] • [[Image:Elug_pdf.png|PDF]] PDF (coming soon)<br />
 
| align="right" valign="bottom" |
 
| align="right" valign="bottom" |
 
{| class="simple oac_no_warn" width="225"
 
{| class="simple oac_no_warn" width="225"
 
|
 
|
 
| align="center" valign="top" |
 
| align="center" valign="top" |
[http://www.google.com/cse/home?cx=016171230611334810008:y5kxq4rqd8s&hl=en Search]
+
[[Image:Elug_Magnifier.png|Search]][http://www.google.com/cse/home?cx=016171230611334810008:y5kxq4rqd8s&hl=en Search]
 
| align="center" valign="top" |
 
| align="center" valign="top" |
[[EclipseLink/UserGuide/JPA/toc| Contents]]
+
&nbsp;&nbsp;&nbsp;[[Image:Elug_guide_icon.png|Contents]][[EclipseLink/UserGuide/JPA/2.4/toc| Contents]]
 
|}
 
|}
 
|}
 
|}

Revision as of 14:18, 19 June 2012


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