Jump to: navigation, search

EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Lazy Basics

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 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:


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.

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

@ManyToOne

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.

@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.

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