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

From Eclipsepedia

Jump to: navigation, search
m (New page: =Lazy Basics= 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 ...)
 
Line 1: Line 1:
 +
{{EclipseLink_UserGuide|info=y}
 
=Lazy Basics=
 
=Lazy Basics=
  
Line 30: Line 31:
 
| id="r2c1-t52" headers="r1c1-t52" align="left" |
 
| id="r2c1-t52" headers="r1c1-t52" align="left" |
 
[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@ManyToMany|many-to-many]]
 
[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@ManyToMany|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" |
 +
[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@OneToMany|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" |
 +
[[Introduction%20to%20EclipseLink%20JPA%20(ELUG)#@OneToOne|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>JPA%20(ELUG)#@ManyToMany|many-to-many]]
 
| headers="r2c1-t52 r1c2-t52" align="left" |
 
| 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).
 
EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default).
Line 73: Line 90:
 
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:
 
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 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]]
+
* [[#How to Configure Static Weaving for JPA Entities|How to Configure
|}
+
<br><sup> 1 </sup>Fully supported in any container that implements the appropriate container contracts in the EJB 3.0 specification.<br>
+
 
+
 
+
{{EclipseLink_JPA
+
|previous=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Column|Default Conversions and Converters]]
+
|next=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Relationship Mappings|Relationship Mappings]]
+
|up=[[EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings|Basic Mappings]]}}
+

Revision as of 15:22, 18 June 2010

{{EclipseLink_UserGuide|info=y}

Lazy Basics

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 lists EclipseLink JPA support for lazy loading by mapping type.

For more information, see the following:


EclipseLink JPA Support for Lazy Loading by Mapping Type

Mapping Java EE 1 Java SE

many-to-many

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

one-to-many

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

one-to-one

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZYJPA%20(ELUG)#@ManyToMany|many-to-many]]

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

one-to-many

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY (default).

one-to-one

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY.

By default, EclipseLink JPA ignores the fetch attribute and default javax.persistence.FetchType.EAGER applies.

To configure EclipseLink JPA to perform lazy loading when the fetch attribute set to FetchType.LAZY, consider one of the following:

many-to-one

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY.

By default, EclipseLink JPA ignores the fetch attribute and default javax.persistence.FetchType.EAGER applies.

To configure EclipseLink JPA to perform lazy loading when the fetch attribute set to FetchType.LAZY, configure one of the following:

basic

EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY.

By default, EclipseLink JPA ignores the fetch attribute and default javax.persistence.FetchType.EAGER applies.

To configure EclipseLink JPA to perform lazy loading when the fetch attribute set to FetchType.LAZY, consider one of the following: