[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Dyn. Weaving, Lazy Collection, Clone Problem
|
Hi,
here some additional information which hopefully help. First of all the
eclipselink version which I am using - it's the current 2.0 RC1. And I
debugged a bit more into the EclipseLink code and here are my observations:
When the cloning is performed an instance of PersistenceEntityCopyPolicy
is being used. Its buildWorkingCopyClone(Object,Session) method is
called which in turn calls the weaved _persistence_shallow_clone()
method of my Bar entity. Unfortunately I couldn't debug into that
method, but it's obvious that after the clone operation both objects
(original and clone) reference the *same* PCS instance - which is wrong
to my mind.
So hopefully somebody can help me out of this situation?! Maybe there is
some configuration option to influence the clone operation.
Thanks in advance,
Oliver
Oliver Vesper schrieb:
Hi,
I have two entities as follows:
@Entity
public class Foo {
@Id
private Long id;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private final Collection<Bar> bars = new ArrayList<Bar>();
}
@Entity
public class Bar {
@Transient
private transient final PropertyChangeSupport pcs = new
PropertyChangeSupport(this);
@Id
private Long id;
@Basic(fetch = FetchType.LAZY)
@Lob
private byte[] data;
}
When calling Foo.getBars() I receive an IndirectList. When accessing
elements of that list, the lazy object (here it's only 1 element) is
being loaded and instantiated. However I can see during debug that there
is some kind of "cloning" going on (registerExistingObject() is being
called). In detail the Bar instance is being "cloned" and afterwards
original and clone both point at the same PCS instance - PCS has a
back-reference to the original Bar instance. But when accessing the list
retrieved by getBars() I have access to the clone whose PCS is messed up.
Any ideas what is going wrong? When weaving is turned off everything
works fine.
I hope the problem is clear enough (it's 2 am over here).
Thanks in advance,
Oliver