|
Re: [CDO] Persisting cross-referenced models [message #508931 is a reply to message #508910] |
Wed, 20 January 2010 17:38 |
|
Hi Gaetan,
This could be a problem with CDO 3.0's "external references" that are
created during the import of your resource B (first import). But I'm not
sure.
We use to import multiple resource with EcoreUtil.copyAll(Collection<?
extends T>) and attach the resulting copies anywhere in your CDO object
graph.
BTW. I'd recommend to use a separate ResourceSet for A and B. You can
throw it away after copyAll().
Cheers
/Eike
----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Gaetan schrieb:
> Hi,
> I have a question with respect to persistance in CDO.
>
> I have two local models (loaded from XMI resources) A and B. Model A
> has some references to model B.
> I would like to persist A and B on the CDO server. I have no problem
> while persisting model B, but model A contains references to B and I
> could not persist those references on CDO.
>
> Here is the code I am using:
> CDOSession session = configuration.openSession();
> CDOTransaction transaction = session.openTransaction();
> ResourceSet cdoResourceSet = transaction.getResourceSet();
>
> // Load resources A and B
> Resource A = cdoResourceSet.getResource(..., true);
> Resource B = cdoResourceSet.getResource(..., true);
>
> // Create cdo resources
> CDOResource cdoResourceA = transaction.getOrCreateResource(...)
> CDOResource cdoResourceB = transaction.getOrCreateResource(...)
> cdoResourceB.addAll(B.getContents()) // This works
> cdoResourceA.addAll(A.getContents())
> transaction.commit(); // This breaks (see below for the exact error)
> transaction.close();
>
> session.close();
>
> Here is the execution error:
>
> [ERROR] The object
> "mailto:org.eclipse.emf.ecore.impl.EObjectImpl@ed41a7 (eProxyURI:
> ../model/OUT.ecore#//@root.0/@elment.0/@element.4)(org.eclip
> se.emf.ecore.impl.EObjectImpl) " is not contained in a resource
>
> My genmodel options:
> Containment Proxies = true
> Feature Delegation = Reflective
>
> Is this the best way to proceed when committing two resources linked
> with cross-document references?
>
> Regards,
> Gaetan.
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Re: [CDO] Persisting cross-referenced models [message #509195 is a reply to message #509150] |
Thu, 21 January 2010 16:03 |
Victor Roldan Betancort Messages: 524 Registered: July 2009 |
Senior Member |
|
|
Gaetan,
the support for external references in DBStore was implemented after CDO
2.0.0 was released.
249610: [DB] Support external references (Implementation)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249610
It supposed to be included in CDO 2.0.0 SR1, but I'm not sure if we
managed to create such build. Eike?
You could take 2.0 code from CVS, it should be implemented :D
Cheers,
Víctor.
Gaetan escribió:
> Hi Eike, thank you for your answer.
>
> I tried the solution you suggested; here is the code from what I
> understood:
> CDOSession session = configuration.openSession();
>
> ResourceSet resourceSet = new ResourceSetImpl();
> // Load resources A and B
> Resource A = resourceSet.getResource(..., true);
> Resource B = resourceSet.getResource(..., true);
>
> CDOTransaction transaction = session.openTransaction();
> ResourceSet cdoResourceSet = transaction.getResourceSet();
>
> // Create cdo resources
> CDOResource cdoResourceA = transaction.getOrCreateResource(...)
> CDOResource cdoResourceB = transaction.getOrCreateResource(...)
>
> cdoResourceB.addAll(EcoreUtil.copyAll(B.getContents()))
> cdoResourceA.addAll(EcoreUtil.copyAll(A.getContents()))
>
> transaction.commit(); // This breaks (see below for the exact error)
> transaction.close();
>
> session.close();
>
> At runtime I get a rather more telling error:
> [ERROR] Rollback in DBStore: java.lang.IllegalArgumentException: DBStore
> does not support external references:
> oid:/XX/XX/model.ecore#//@element.4/@element.22
>
> As I understand it, it seems like there is a problem with references
> reconcilation at commit.
>
> Should I suppose that CDO will automatically "convert" local references
> to proper "CDO" ones? If so, what am I doing wrong? If not, what would
> be the proper pattern to convert cross documents references?
>
> Note that since A and B are distinct models, I would be interested in
> keeping them in separate CDO resources.
>
> In my first post I forgot to state the CDO version I use (2.0). Would
> switching to a higher version solve my problem? Is version 3.0 stable
> enough for general use?
>
>
> Regards,
> Gaetan.
>
|
|
|
Re: [CDO] Persisting cross-referenced models [message #509196 is a reply to message #509195] |
Thu, 21 January 2010 16:05 |
Victor Roldan Betancort Messages: 524 Registered: July 2009 |
Senior Member |
|
|
Sorry, wrong bug. The correct one for 2.0 is this one:
289237: [DB] Support external references
https://bugs.eclipse.org/bugs/show_bug.cgi?id=289237
:)
Víctor Roldán Betancort escribió:
> Gaetan,
>
> the support for external references in DBStore was implemented after CDO
> 2.0.0 was released.
>
> 249610: [DB] Support external references (Implementation)
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=249610
>
> It supposed to be included in CDO 2.0.0 SR1, but I'm not sure if we
> managed to create such build. Eike?
>
> You could take 2.0 code from CVS, it should be implemented :D
>
> Cheers,
> Víctor.
>
> Gaetan escribió:
>> Hi Eike, thank you for your answer.
>>
>> I tried the solution you suggested; here is the code from what I
>> understood:
>> CDOSession session = configuration.openSession();
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>> // Load resources A and B
>> Resource A = resourceSet.getResource(..., true);
>> Resource B = resourceSet.getResource(..., true);
>>
>> CDOTransaction transaction = session.openTransaction();
>> ResourceSet cdoResourceSet = transaction.getResourceSet();
>>
>> // Create cdo resources
>> CDOResource cdoResourceA = transaction.getOrCreateResource(...)
>> CDOResource cdoResourceB = transaction.getOrCreateResource(...)
>>
>> cdoResourceB.addAll(EcoreUtil.copyAll(B.getContents()))
>> cdoResourceA.addAll(EcoreUtil.copyAll(A.getContents()))
>>
>> transaction.commit(); // This breaks (see below for the exact error)
>> transaction.close();
>>
>> session.close();
>>
>> At runtime I get a rather more telling error:
>> [ERROR] Rollback in DBStore: java.lang.IllegalArgumentException:
>> DBStore does not support external references:
>> oid:/XX/XX/model.ecore#//@element.4/@element.22
>>
>> As I understand it, it seems like there is a problem with references
>> reconcilation at commit.
>>
>> Should I suppose that CDO will automatically "convert" local
>> references to proper "CDO" ones? If so, what am I doing wrong? If not,
>> what would be the proper pattern to convert cross documents references?
>>
>> Note that since A and B are distinct models, I would be interested in
>> keeping them in separate CDO resources.
>>
>> In my first post I forgot to state the CDO version I use (2.0). Would
>> switching to a higher version solve my problem? Is version 3.0 stable
>> enough for general use?
>>
>>
>> Regards,
>> Gaetan.
>>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05525 seconds