Skip to main content



      Home
Home » Modeling » EMF » [CDO] Persisting cross-referenced models
[CDO] Persisting cross-referenced models [message #508910] Wed, 20 January 2010 12:12 Go to next message
Eclipse UserFriend
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 "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.

Re: [CDO] Persisting cross-referenced models [message #508931 is a reply to message #508910] Wed, 20 January 2010 12:38 Go to previous messageGo to next message
Eclipse UserFriend
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.
>
>
Re: [CDO] Persisting cross-referenced models [message #509150 is a reply to message #508931] Thu, 21 January 2010 09:14 Go to previous messageGo to next message
Eclipse UserFriend
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 #509195 is a reply to message #509150] Thu, 21 January 2010 11:03 Go to previous messageGo to next message
Eclipse UserFriend
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 11:05 Go to previous messageGo to next message
Eclipse UserFriend
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.
>>
Re: [CDO] Persisting cross-referenced models [message #509355 is a reply to message #509196] Fri, 22 January 2010 03:46 Go to previous messageGo to next message
Eclipse UserFriend
Hi Victor, Eike,

I checked out the CVS branch R2_maintenance ( server:anonymous@dev.eclipse.org:/cvsroot/modeling), which solved my problem.

Thank you,
Gaetan.

[Updated on: Fri, 22 January 2010 03:47] by Moderator

Re: [CDO] Persisting cross-referenced models [message #509359 is a reply to message #509355] Fri, 22 January 2010 03:53 Go to previous message
Eclipse UserFriend
Gaetan schrieb:
> Hi Victor, Heike,
Eike ;-)

> I checked out the CVS branch R2_maintenance
R2_0_maintenance ;-)

> ( server:mailto:anonymous@dev.eclipse.org:/cvsroot/modeling), which
> solved my problem.
Excellent.

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Previous Topic:CDO 3.0 dependency on Helios
Next Topic:[CDO] Graceful server shutdown when running without a console
Goto Forum:
  


Current Time: Wed Jul 23 15:17:54 EDT 2025

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

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

Back to the top