[CDO] ChangedInTargetAndDetachedInSourceConflict resolution [message #1855630] |
Mon, 24 October 2022 12:47  |
Eclipse User |
|
|
|
Hi,
Consider the following use case:
- EObjects A and B exist in the CDO repository with no relation between them
- Client 1 creates EObject A1 as child of A
- Client 1 makes a reference to A1 in B
- Client 2 deletes A and commit
- Client 1 gets the conflict ChangedInTargetAndDetachedInSourceConflict for A
I try to apply a generic resolution for this conflict: delete A, all its children and the references to them.
I found a solution that works but I'm not sure if it's the proper way.
I use a MergingConflictResolver and override the resolveConflicts(Set<CDOObject> conflicts, CDOChangeSet remoteChangeSet) to do for each ChangedInTargetAndDetachedInSourceConflict:
internalCDOObject.cdoInternalSetState(CDOState.CONFLICT);
CDOStateMachine.INSTANCE.detach(internalCDOObject);
lastSavePoint.getDetachedObjects().remove(vCDOID);
A and A1 are deleted but the reference to A1 still exists in B. To remove it, I apply on the new objects removed during the conflict resolution, the the same treatment as in the beginning of the invalidate() method of CDOTransactionImpl:
removeCrossReferences(deletedNewObjects, lastSavePoint.getDirtyObjects().values());
removeCrossReferences(deletedNewObjects, lastSavePoint.getNewObjects().values());
(I had to copy the removeCrossReferences() method, could it be possible to make it not private?)
Is it the best solution to get the desired result?
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02963 seconds