Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Lazy Basics"

m
Line 27: Line 27:
 
* [[#What You May Need to Know About Weaving JPA Entities|What You May Need to Know About Weaving JPA Entities]]
 
* [[#What You May Need to Know About Weaving JPA Entities|What You May Need to Know About Weaving JPA Entities]]
 
-->
 
-->
 
<span id="Table 19-33"></span>
 
''''' EclipseLink JPA Support for Lazy Loading by Mapping Type'''''
 
 
{| class="RuleFormalWideMax" dir="ltr" title="EclipseLink JPA Support for Lazy Loading by Mapping Type" summary="This table lists EclipseLink JPA mapping support for lazy loading by mapping type for Java EE (in container) and Java SE (outside of container) applications." width="100%" border="1" frame="border" rules="all" cellpadding="3" frame="border" rules="all"
 
|- align="left" valign="top"
 
! id="r1c1-t52" align="left" valign="bottom" | '''Mapping'''
 
! id="r1c2-t52" align="left" valign="bottom" | '''Java EE''' <sup> 1 </sup>
 
! id="r1c3-t52" align="left" valign="bottom" | '''Java SE'''
 
|- align="left" valign="top"
 
| id="r2c1-t52" headers="r1c1-t52" align="left" |
 
Many-to_many
 
| headers="r2c1-t52 r1c2-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default).
 
| headers="r2c1-t52 r1c3-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default).
 
 
|- align="left" valign="top"
 
| id="r3c1-t52" headers="r1c1-t52" align="left" |
 
One-to-many
 
| headers="r3c1-t52 r1c2-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default).
 
| headers="r3c1-t52 r1c3-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default).
 
 
|- align="left" valign="top"
 
| id="r4c1-t52" headers="r1c1-t52" align="left" |
 
One-to-one
 
| headers="r4c1-t52 r1c2-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt>.
 
| headers="r4c1-t52 r1c3-t52" align="left" |
 
By default, EclipseLink JPA ignores the <tt>fetch</tt> attribute and default javax.persistence.<tt>FetchType.EAGER</tt> applies.
 
<!--
 
To configure EclipseLink JPA to perform lazy loading when the <tt>fetch</tt> attribute set to <tt>FetchType.LAZY</tt>, consider one of the following:
 
* [[#How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent|How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent]]
 
* [[#How to Configure Static Weaving for JPA Entities|How to Configure Static Weaving for JPA Entities]]
 
-->
 
 
|- align="left" valign="top"
 
| id="r5c1-t52" headers="r1c1-t52" align="left" |
 
Many-to-one
 
| headers="r5c1-t52 r1c2-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt>.
 
| headers="r5c1-t52 r1c3-t52" align="left" |
 
By default, EclipseLink JPA ignores the <tt>fetch</tt> attribute and default <tt>javax.persistence.FetchType.EAGER</tt> applies.
 
<!--
 
To configure EclipseLink JPA to perform lazy loading when the <tt>fetch</tt> attribute set to <tt>FetchType.LAZY</tt>, configure one of the following:
 
* [[#How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent|How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent]]
 
* [[#How to Configure Static Weaving for JPA Entities|How to Configure Static Weaving for JPA Entities]]
 
-->
 
 
|- align="left" valign="top"
 
| id="r6c1-t52" headers="r1c1-t52" align="left" |
 
Basic
 
| headers="r6c1-t52 r1c2-t52" align="left" |
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt>.
 
| headers="r6c1-t52 r1c2-t52" align="left" |
 
By default, EclipseLink JPA ignores the <tt>fetch</tt> attribute and default javax.persistence.<tt>FetchType.EAGER</tt> applies.
 
<!--
 
To configure EclipseLink JPA to perform lazy loading when the <tt>fetch</tt> attribute set to <tt>FetchType.LAZY</tt>, consider one of the following:
 
* [[#How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent|How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent]]
 
* [[#How to Configure Static Weaving for JPA Entities|How to Configure Static Weaving for JPA Entities]]
 
-->
 
|}
 
  
 
{{EclipseLink_JPA
 
{{EclipseLink_JPA

Revision as of 10:00, 19 December 2012

EclipseLink JPA

link="http://wiki.eclipse.org/EclipseLink"
EclipseLink
Website
Download
Community
Mailing ListForumsIRC
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse Source

Elug api package icon.png Key API


Lazy Loading

JPA specifies that lazy loading is a hint to the persistence provider that data should be fetched lazily when it is first accessed, if possible.

If you are developing your application in a Java EE environment, you only have to set fetch to javax.persistence.FetchType.LAZY, and EclipseLink persistence provider will supply all the necessary functionality.

When using a one-to-one or many-to-one mapping in a Java SE environment, to configure EclipseLink JPA to perform lazy loading when the fetch attribute is set to FetchType.LAZY, configure either dynamic or static weaving.

When using a one-to-one or many-to-one mapping in a Java SE environment that does not permit the use of -javaagent on the JVM command line, to configure EclipseLink JPA to perform lazy loading when annotation attribute fetch is set to javax.persistence.FetchType.LAZY, you can use static weaving.

The EclipseLink JPA Support for Lazy Loading by Mapping Type table, below, lists EclipseLink JPA support for lazy loading by mapping type.


Eclipselink-logo.gif
Version: 2.2.0 DRAFT
Other versions...