Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Having issues with CopyGroup

That's because depth 4 currently is not defined so no copying happens at all; and depth 3 processed according to the new CASCADE_TREE path instead of the old CASCADE_ALL_PARTS path.
The only way is to fix CASCADE_TREE value and recompile Eclipselink

On 7/30/2010 3:56 PM, Kevin Haskett wrote:
So instead of hacking the CopyGroup class I just changed the call from cascadeAllParts() to setDepth(4);
 
Unfortunately this is not doing what I had anticipated.  Now after the entityManager.getActiveSession().copy(entity, copyGroup);
the returned entity is still pointing to the old object tree.
 
In my case new cpTransaction has the reference to the previous CpLob, it is not creating a new instance of it as it had in previous versions.
 
Thanks,
Kevin
 

From: eclipselink-users-bounces@xxxxxxxxxxx [mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Andrei Ilitchev
Sent: Friday, July 30, 2010 12:48 PM
To: EclipseLink User Discussions
Subject: Re: [eclipselink-users] Having issues with CopyGroup

This will be fixed in 2.1.1

The reason for this is my stupid mistake - the newly introduced CASCADE_TREE constant is equal to preexisting CASCADE_ALL_PARTS.
That causes CASCADE_TREE  being performed instead of CASCADE_ALL_PARTS.

Unfortunately there is no workaround.

The only thing you can do is to hack CopyGroup and apply the same fix 2.1.1 does:
substitute:
    public static final int CASCADE_TREE = 3;
for:
    public static final int CASCADE_TREE = 4;

I apologize for the mess,

Andrei

On 7/30/2010 11:55 AM, Kevin Haskett wrote:
I am having an issue with the CopyGroup using Eclipselink 2.1, not sure when this started showing up as this seemed to work on a previous version, possibly 1.3?
 
It is a somewhat large object graph and in previous version when we used  ObjectCopyingPolicy it seemed to copy the whole object tree and reset the primary keys and then when persisted would give us a duplicate copy of the whole object tree.
 
Here is our code now using CopyGroup -
 
        final CopyGroup copyGroup = new CopyGroup();
        copyGroup.cascadeAllParts();
        copyGroup.setShouldResetPrimaryKey(true);
 
        return (CpTransaction) entityManager.getActiveSession().copy(entity, copyGroup);
The problem is that it seems to create the whole object tree but it doesn't set the relationship objects correctly.
 
Right now the top level object is CpTransaction, with a relationship to CpLobs
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cpTransaction")
    @PrivateOwned
    private Set<CpLob> cpLobs = new HashSet<CpLob>(0);
CpLobs looks like -
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "TRANSACTION_ID", nullable = false)
    private CpTransaction cpTransaction;
When I look at the new CpTransaction after the copy it has the new cpLob item in the HashSet, but the CpLob item's parent cpTransaction is null.  If I leave it at CASCADE_PRIVATE_PARTS, then it seems to set the cpTransaction parent, but it doesn't seem to cascade down any further into the object graph than the 2nd Level.
 
Thanks,
Kevin
 

This message (including any attachments) is intended only for the use of the individual or entity to which it is addressed and may contain information that is non-public, proprietary, privileged, confidential, and exempt from disclosure under applicable law or may constitute as attorney work product. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, notify us immediately by telephone and (i) destroy this message if a facsimile or (ii) delete this message immediately if this is an electronic communication. Thank you.


_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

This message (including any attachments) is intended only for the use of the individual or entity to which it is addressed and may contain information that is non-public, proprietary, privileged, confidential, and exempt from disclosure under applicable law or may constitute as attorney work product. If you are not the intended recipient, you are hereby notified that any use, dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, notify us immediately by telephone and (i) destroy this message if a facsimile or (ii) delete this message immediately if this is an electronic communication. Thank you.


_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top