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 |
|
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 |
|
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
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] adding and removing CDOResource from ResourceSet [message #669250 is a reply to message #668633] |
Mon, 09 May 2011 15:20 |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Fri Apr 19 10:39:25 GMT 2024
Powered by FUDForum. Page generated in 0.01846 seconds
|