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.
Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Lazy Basics"
m |
m |
||
Line 14: | Line 14: | ||
If you are developing your application in a Java EE environment, you only have to set fetch to <tt>javax.persistence.FetchType.LAZY</tt>, and EclipseLink persistence provider will supply all the necessary functionality. | If you are developing your application in a Java EE environment, you only have to set fetch to <tt>javax.persistence.FetchType.LAZY</tt>, and EclipseLink persistence provider will supply all the necessary functionality. | ||
− | When using a | + | When using a @OneToOne or #@ManyToOne mapping in a Java SE environment, to configure EclipseLink JPA to perform lazy loading when the <tt>fetch</tt> attribute is set to <tt>FetchType.LAZY</tt>, configure either dynamic or static weaving. |
− | When using a | + | When using a @OneToOne or @ManyToOne mapping in a Java SE environment that does not permit the use of <tt>-javaagent</tt> on the JVM command line, to configure EclipseLink JPA to perform lazy loading when annotation attribute <tt>fetch</tt> is set to <tt>javax.persistence.FetchType.LAZY</tt>, you can use static weaving. |
− | The [[#Table 19-33|EclipseLink JPA Support for Lazy Loading by Mapping Type]] table lists EclipseLink JPA support for lazy loading by mapping type. | + | The [[#Table 19-33|EclipseLink JPA Support for Lazy Loading by Mapping Type]] table, below, lists EclipseLink JPA support for lazy loading by mapping type. |
For more information, see the following: | For more information, see the following: | ||
Line 37: | Line 37: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r2c1-t52" headers="r1c1-t52" align="left" | | | id="r2c1-t52" headers="r1c1-t52" align="left" | | ||
− | + | @ManyToMany | |
| 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 44: | Line 44: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t52" headers="r1c1-t52" align="left" | | | id="r3c1-t52" headers="r1c1-t52" align="left" | | ||
− | + | @OneToMany | |
| headers="r3c1-t52 r1c2-t52" align="left" | | | 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). | EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default). | ||
Line 51: | Line 51: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t52" headers="r1c1-t52" align="left" | | | id="r4c1-t52" headers="r1c1-t52" align="left" | | ||
− | + | @OneToOne | |
| headers="r4c1-t52 r1c2-t52" align="left" | | | 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]] | + | 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 60: | Line 60: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r3c1-t52" headers="r1c1-t52" align="left" | | | id="r3c1-t52" headers="r1c1-t52" align="left" | | ||
− | + | @OneToMany | |
| headers="r3c1-t52 r1c2-t52" align="left" | | | 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). | EclipseLink JPA performs lazy loading when the <tt>fetch</tt> attribute is set to <tt>javax.persistence.FetchType.LAZY</tt> (default). | ||
Line 67: | Line 67: | ||
|- align="left" valign="top" | |- align="left" valign="top" | ||
| id="r4c1-t52" headers="r1c1-t52" align="left" | | | id="r4c1-t52" headers="r1c1-t52" align="left" | | ||
− | + | @OneToOne | |
| headers="r4c1-t52 r1c2-t52" align="left" | | | 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>. | 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" | | | 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. | 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: | 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: | ||
Line 97: | Line 98: | ||
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 | + | * [[#How to Configure Static Weaving for JPA Entities|How to Configure]] |
|} | |} | ||
Revision as of 16:43, 2 May 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
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 @OneToOne or #@ManyToOne 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 @OneToOne or @ManyToOne 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.
For more information, see the following:
- How to Configure Dynamic Weaving for JPA Entities Using the EclipseLink Agent
- How to Configure Static Weaving for JPA Entities
- How to Disable Weaving Using EclipseLink Persistence Unit Properties
- What You May Need to Know About Weaving JPA Entities
EclipseLink JPA Support for Lazy Loading by Mapping Type
Mapping | Java EE 1 | Java SE | |
---|---|---|---|
@ManyToMany |
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). | |
@OneToMany |
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). | |
@OneToOne |
EclipseLink JPA performs lazy loading when the fetch attribute is set to javax.persistence.FetchType.LAZY JPA%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). |
@OneToMany |
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). | |
@OneToOne |
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: |
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: | ||
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: |