Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
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:
FetchType.LAZY
: when the entity is retrieved, the persistent field value is not retrieved. The value is retrieved if and when the field is accessed.
FetchTyep.EAGER
: when the entity is retrieved, the persistent field value is also retrieved.
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".
Example 7-29 shows how to use the @Basic
annotation to define a fetch strategy of LAZY
.