Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Lazy loading can operate when persistence context is closed?

Hi,

The JPA specification does not specify what the persistence provider should do to lazy relationships when the persistence context is closed. EclipseLink has chosen to retrieve them when possible.

Our implementation of lazy relationships for xToMany relationships does not require the use of weaving. We, instead, use a subclass of your collection class. (In your case we use a class called IndirectList - if you want, you can take a look at it in the source to see what it does.)

-Tom

fcalfo wrote:


fcalfo wrote:
Doesn't the persistence context have to be open for a lazy loaded
collection to be fetched?

I am making sure to run the static weaver
(org.eclipse.persistence.tools.weaving.jpa.StaticWeave) before running my
test.




More info on this: while inspecting the Contract.class file after the static
weaver was applied, it looks like
it didn't weave in the lazy loading.

Here's the class definition from the class file after StaticWeave was run:

public class jpa.Contract implements java.lang.Cloneable,
org.eclipse.persistence.internal.weaving.PersistenceWeaved,
org.eclipse.persistence.internal.descriptors.PersistenceEntity,
org.eclipse.persistence.internal.descriptors.PersistenceObject {

It did something since it added the PersistenceWeaved interface

but it should have also added the PersistenceWeavedLazy interface.

Why didn't it add that even though I added the lazy fetch type on the
supplierContracts collection and the eclipselink.weaving.lazy property is
set to true?

(I do have this working on another class so I'm wondering what I'm missing
here)


Back to the top