Skip Headers
Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide
10g (10.1.3.5.0)

Part Number E13981-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

Configuring Lazy Loading

For all EJB 3.0 mapping types (basic and relationship mappings), you can define the strategy for fetching data from the database as one of the following:

By default, all persistent fields are fetched eagerly.

If you are using finders in your EJB 3.0 application, you can configure lazy loading at the finder level. This is an Oracle-specific option that you configure using the EJB 2.1 orion-ejb-jar.xml file. For more information, see "Configuring Lazy Loading on Finder Methods".

Using Annotations

Example 7-29 shows how to use the @Basic annotation to define a fetch strategy of LAZY.

Example 7-29 @Basic Fetch Attribute

@Basic(fetch=FetchType.LAZY)
@Column(name="F_NAME")
public String getFirstName() {
    return firstName;
}