In my test scenario I have the classes "Customer" and "Account" and a 0..* containment reference "accounts", so a customer may own many accounts. When I call
customer1.getAccounts().add(account1);
EMF first performs some checks and then calls
1. myStore.add(customer1, reference, index, account1);
which is fine. myStore persists account1 and remembers its new container, customer1. Then EMF asks myStore for the container of account1:
2. myStore.getContainer(account1)
and myStore returns "customer1" which was just passed to myStore.add(). Then EMF decides to remove account1 from its container and calls:
3. myStore.remove(customer1, reference, index)
It looks like DelegatingNotifyingListImpl.addUnique() first calls addUnique() and then inverseAdd() which in turn calls eBasicRemoveFromContainer().
I would understand if EMF did something like:
oldContainer = store.getContainer(object);
if (oldContainer != null)
removeFromContainer(oldContainer, object);
store.add(newContainer, object);
but it looks like:
store.add(newContainer, object);
oldContainer = store.getContainer(object);
if (oldContainer != null)
removeFromContainer(oldContainer, object);
Any ideas what went wrong?
Thanks in advance,
Andreas
]]>