persistence@glassfish.java.net

Re: Need Doc help on Lazy Loading

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 12 Dec 2006 13:38:52 -0800

Tom,

What happens if any other field or property (e.g. LOB) is marked as LAZY?
Are they treated the same way as the ToOne relationship?

thanks,
-marina

Tom Ware wrote:
> Hi,
>
> Here's some additional information.
>
> TopLink Essentials uses some fundamental TopLink features to implement
> indirection.
> 1. For OneToMany and ManyToOne, TopLink weaves your classes to include
> implementations of TopLink's ValueHolderInterface
> 2. For OneToMany and ManyToMany, TopLink uses a feature called
> transparent indirection
>
> Here is a pointer to the documentation for those features for the
> non-JPA TopLink product.
>
> http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/mapun002.htm#CHDJAHDC
>
>
> -Tom
>
> Peter Krogh wrote:
>
>> ToOnes (One to ones and Many to Ones) and ToManys (one to manys and
>> many to manys) relationships work differently with respect to lazy
>> loading.
>>
>>
>>> - in a One to Many mapping would company.getLocations() load the many
>>> side (Location) or is it expected to get loaded only on doing something
>>> with it eg: company.getLocations().iterator()?
>>>
>>
>>
>> in this example 'locations' would get loaded when you call something
>> on the collection. This is because TopLink Essentials has its own
>> Collection implementation that lazily loads relationships. In order
>> for the relationship to be loaded, an action must be performed on
>> TopLink Essentials Collection class.
>>
>>
>>
>>> - Same question for Many To One, when will the relationship be loaded,
>>> on execution of employee.getDepartment() or
>>> employee.getDepartment().getName()?
>>>
>>
>>
>> Department would get loaded when you call getDepartment(). This is
>> because TopLink Essentials weaves in a proxy class (ValueHolder) for
>> one to one (and many to one) relationships. The method access is
>> woven to trigger the proxy.
>>
>> Peter
>>
>> -----Original Message-----
>> From: Varun.Rupela_at_Sun.COM [mailto:Varun.Rupela_at_Sun.COM]On Behalf Of
>> Varun Rupela
>> Sent: Monday, December 11, 2006 11:47 PM
>> To: persistence_at_glassfish.dev.java.net
>> Subject: Need Doc help on Lazy Loading
>>
>>
>> Hi:
>>
>> Kindly help with the below question. Pointers to docs that describe
>> toplink's lazy loading feature will be greatly appreciated.
>>
>> When is a relationship loaded if the fetch attribute is set to LAZY- on
>> use of the getter or when doing an operation on the relationship entity
>> after using the getter. Example:
>> - in a One to Many mapping would company.getLocations() load the many
>> side (Location) or is it expected to get loaded only on doing something
>> with it eg: company.getLocations().iterator()?
>> - Same question for Many To One, when will the relationship be loaded,
>> on execution of employee.getDepartment() or
>> employee.getDepartment().getName()?
>>
>> I found
>> http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#LazyLoading
>>
>> but it does not help with the above question.
>>
>> thanks.
>>
>> varun.
>>
>>