Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] ChangedInTargetAndDetachedInSourceConflict resolution
[CDO] ChangedInTargetAndDetachedInSourceConflict resolution [message #1855630] Mon, 24 October 2022 16:47 Go to next message
Vincent Sennedot is currently offline Vincent SennedotFriend
Messages: 10
Registered: March 2015
Junior Member
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?
Re: [CDO] ChangedInTargetAndDetachedInSourceConflict resolution [message #1855826 is a reply to message #1855630] Sun, 06 November 2022 07:33 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Vincent,

When you want to use internals of CDOTransactionImpl you're generally on your own.
We won't make removeCrossReferences() public, but you could try to use reflection.

It's impossible to tell whether your solution is the best.
Even to tell whether it's correct is hard because I don't see the full code and have no easy means to reproduce the problem.

Sorry ;-)


Re: [CDO] ChangedInTargetAndDetachedInSourceConflict resolution [message #1855842 is a reply to message #1855826] Mon, 07 November 2022 14:39 Go to previous messageGo to next message
Vincent Sennedot is currently offline Vincent SennedotFriend
Messages: 10
Registered: March 2015
Junior Member
Thanks for your answer.
I understand that it's difficult to say if my way is the best or not.

But in fact, I was just wondering if there is a generic way to do it as in CDOMergingResolver there is the handleConflict() method that can be overridden but I can't manage this type of conflict as the updateTransactionWithResult() method called next, only manage the changed objects, not the detached ones.
Re: [CDO] ChangedInTargetAndDetachedInSourceConflict resolution [message #1855847 is a reply to message #1855842] Mon, 07 November 2022 16:58 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Perhaps you want to provide a patch to enhance CDOMergingConflictResolver.updateTransactionWithResult() so that it interprets CDOChangeSetData.getDetachedObjects(), too?

Re: [CDO] ChangedInTargetAndDetachedInSourceConflict resolution [message #1855867 is a reply to message #1855847] Tue, 08 November 2022 10:21 Go to previous message
Vincent Sennedot is currently offline Vincent SennedotFriend
Messages: 10
Registered: March 2015
Junior Member
I would like to, but I'm not sure how to do it, hence this topic. I may look into it in the coming days.
Previous Topic:[CDO] Sporadic IOException: String ID unknown
Next Topic:[CDO] Outdated lock state when releasing a durable lock
Goto Forum:
  


Current Time: Thu May 02 12:26:52 GMT 2024

Powered by FUDForum. Page generated in 0.03862 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top