Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] adding and removing CDOResource from ResourceSet(Issue encountered when trying to add a removed CDOResource from a CDOTransaction's ResourceSet)
[CDO] adding and removing CDOResource from ResourceSet [message #668633] Fri, 06 May 2011 14:05 Go to next message
Alex Lagarde is currently offline Alex LagardeFriend
Messages: 193
Registered: May 2010
Senior Member

Hi everyone !

Here is a pretty annoying issue that I encountered with CDO. Maybe I'm doing something wrong...


1. Issue description

After I've opened a CDOTransaction on a resourceSet, I add CDOResources to this resourceSet and modify them.

When I'm done editing a CDOResource, I would like to be able to remove it properly from the resourceSet and the transaction, and to add it again later.

2. The bug

After I've unloaded my CDOResource and removed it from the CDOTransaction's resourceSet, when I try to load the CDOResource I get a "Duplicate ID" exception.

After a short investigation, it appears my CDOTransaction still references the removed CDOResource through the AsbstractCDOView.objects map. So when I try to add the CDOResource again, the transaction thinks it's already loaded and throw the Duplicate ID exception.

3. An ugly fix

The only way that I've found is to call the CDOTransactionImpl.deregisterObject method on the CDOResource and all its contained CDOObjects, that removes them from the "objects" map, so that when it is reloaded the new CDOResource and its contained CDOObjects are correctly registered.

This sounds ugly, and it is, but it's doing the job and I can't see other way to be delete the unloaded elements from the Map.

Do you see any better solution ? If not, don't yo think that it is the CDOTransaction's responsability to clear its map ?

Thanks for your time,
Alex
Re: [CDO] adding and removing CDOResource from ResourceSet [message #668677 is a reply to message #668633] Fri, 06 May 2011 16:42 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Alex,

In fact the resource is managed by the transaction, including internal state within the transaction and the associated savepoints. It gets even more complicated if the resource or any of the contained and loaded objects are in dirty state. So far these managed resources are not expected to be removed from the resource set the transaction is associated with. We could think about adding this ability but the implications can be subtle and I'd like to understand better why you want to do this.

If the transaction is not dirty the approach you're describing sounds straight forward, although it certainly involves usage of non-public API (SPI).

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 06.05.2011 16:05, schrieb alagarde:
> Hi everyone !
> Here is a pretty annoying issue that I encountered with CDO. Maybe I'm doing something wrong...
>
>
> 1. Issue description
>
> After I've opened a CDOTransaction on a resourceSet, I add CDOResources to this resourceSet and modify them.
>
> When I'm done editing a CDOResource, I would like to be able to remove it properly from the resourceSet and the transaction, and to add it again later.
>
> 2. The bug
>
> After I've unloaded my CDOResource and removed it from the CDOTransaction's resourceSet, when I try to load the CDOResource I get a "Duplicate ID" exception.
> After a short investigation, it appears my CDOTransaction still references the removed CDOResource through the AsbstractCDOView.objects map. So when I try to add the CDOResource again, the transaction thinks it's already loaded and throw the Duplicate ID exception.
>
> 3. An ugly fix
> The only way that I've found is to call the CDOTransactionImpl.deregisterObject method on the CDOResource and all its contained CDOObjects, that removes them from the "objects" map, so that when it is reloaded the new CDOResource and its contained CDOObjects are correctly registered.
>
> This sounds ugly, and it is, but it's doing the job and I can't see other way to be delete the unloaded elements from the Map.
> Do you see any better solution ? If not, don't yo think that it is the CDOTransaction's responsability to clear its map ?
>
> Thanks for your time,
> Alex


Re: [CDO] adding and removing CDOResource from ResourceSet [message #669250 is a reply to message #668633] Mon, 09 May 2011 15:20 Go to previous message
Eclipse UserFriend
Originally posted by:

Hi Alex,

this issue has been detected some time ago, and there was some effort to
fix it on the way:

338921: Cannot load resource on a previously cleared ResourceSet
https://bugs.eclipse.org/bugs/show_bug.cgi?id=338921

The provided patch fixes the problem, but there are some issues pending
to be discussed. In the meanwhile, you can use it safely.

Cheers,
Víctor.

alagarde escribió:
> Hi everyone !
> Here is a pretty annoying issue that I encountered with CDO. Maybe I'm
> doing something wrong...
>
>
> 1. Issue description
>
> After I've opened a CDOTransaction on a resourceSet, I add CDOResources
> to this resourceSet and modify them.
>
> When I'm done editing a CDOResource, I would like to be able to remove
> it properly from the resourceSet and the transaction, and to add it
> again later.
>
> 2. The bug
>
> After I've unloaded my CDOResource and removed it from the
> CDOTransaction's resourceSet, when I try to load the CDOResource I get a
> "Duplicate ID" exception.
> After a short investigation, it appears my CDOTransaction still
> references the removed CDOResource through the AsbstractCDOView.objects
> map. So when I try to add the CDOResource again, the transaction thinks
> it's already loaded and throw the Duplicate ID exception.
>
> 3. An ugly fix
> The only way that I've found is to call the
> CDOTransactionImpl.deregisterObject method on the CDOResource and all
> its contained CDOObjects, that removes them from the "objects" map, so
> that when it is reloaded the new CDOResource and its contained
> CDOObjects are correctly registered.
>
> This sounds ugly, and it is, but it's doing the job and I can't see
> other way to be delete the unloaded elements from the Map.
> Do you see any better solution ? If not, don't yo think that it is the
> CDOTransaction's responsability to clear its map ?
>
> Thanks for your time,
> Alex
Previous Topic:Empty namespace URI in ecore?
Next Topic:Import XMI files into database
Goto Forum:
  


Current Time: Fri Apr 19 10:39:25 GMT 2024

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

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

Back to the top