Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 346378

Summary: [Legacy] Deleting legacy elements failure
Product: [Modeling] EMF Reporter: Alex Lagarde <alex.lagarde>
Component: cdo.legacyAssignee: Martin Fluegge <martin.fluegge>
Status: CLOSED WORKSFORME QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: stepper
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
A simple metamodel allowing to reproduce this issue none

Description Alex Lagarde CLA 2011-05-19 03:49:06 EDT
Created attachment 196077 [details]
A simple metamodel allowing to reproduce this issue

Issue description
===================
When using a very simple metamodel in legacy mode, the objects wrapped by the CDOLegacyWrapper are not properly deleted.

When trying to delete a "Car" for its "Garage" container (contained in the "cars" reference), the following methods are called : 

CDOLegacyAdapter(CDOLegacyWrapper).adjustOppositeReference(InternalCDOObject, EObject, EReference) line: 809	
CDOLegacyAdapter(CDOLegacyWrapper).cdoInternalPostDetach(boolean) line: 173	
CDOStateMachine.detach(InternalCDOObject) line: 271	
CDOResourceImpl.detached(EObject) line: 1187	
CarImpl(BasicEObjectImpl).eBasicSetContainer(InternalEObject, int, NotificationChain) line: 1334	
CarImpl(BasicEObjectImpl).eInverseRemove(InternalEObject, int, Class<?>, NotificationChain) line: 1451	
EObjectContainmentEList$Resolving<E>(EcoreEList<E>).inverseRemove(E, NotificationChain) line: 328	
EObjectContainmentEList$Resolving<E>(NotifyingListImpl<E>).remove(int) line: 716	
EObjectContainmentEList$Resolving<E>(AbstractEList<E>).remove(Object) line: 466	
EcoreUtil.remove(EObject, EStructuralFeature, Object) line: 3030

When I inspect the container just after the call to ECoreUtil.remove, my Garage still contains the deleted Car. 
However, calling deletedCar.eContainer() returns null.

Possible causes
===================
CDOLegacyWrapper.adjustOppositeReference() calls CDOLegacyWrapper.adjustTransientOppositeReference(), which adds the deleted Car to the "cars" reference of the Garage. This does not seems right, but you must have a good reason to do so.
Comment 1 Martin Fluegge CLA 2011-05-19 04:23:09 EDT
Hi Alex,

could you try to reproduce this issue with HEAD. The Legacy wrapper currently does not use the method *adjustOppositeReference(InternalCDOObject,
EObject, EReference)* anymore. Which version of CDO are you using?
Comment 2 Alex Lagarde CLA 2011-05-27 09:18:24 EDT
Hi Martin,

sorry for the delay, updating our environment was not what one could call an easy task :)

I've tried to reproduce this issue on the latest stable build (RC2a), it now works fine.

Thanks for your help !
Alex
Comment 3 Martin Fluegge CLA 2011-05-27 12:33:16 EDT
You are welcome :)
Comment 4 Eike Stepper CLA 2012-09-21 06:51:16 EDT
Closing.