Skip to main content



      Home
Home » Modeling » EMF » [CDO] Best Practices: how to save a CDObject with unsaved references
[CDO] Best Practices: how to save a CDObject with unsaved references [message #896266] Tue, 17 July 2012 15:39 Go to next message
Eclipse UserFriend
In my case, I need to create a "complex" graph object model from scratch. For example, a country has localized names. Each localized name makes references to a language and a country so there are loops in the graph. In this example, these classes are connected logically by EMF EReference links.

When I call to a service to persist one country from the model by CDO client, this service does know nothing if other ereferences associated entities are yet saved into a resource or not. So if service adds the country to a resource and does commit, an exception could be thrown because some of the associated entities are not included in any resource.
Is the situation to try to persist only one country a bad practice?


What is the best practice to persist the graph model?


Does CDO provide a method to include "automatically" ereference linked objects that are not yet included into any resource?

[Updated on: Tue, 17 July 2012 16:13] by Moderator

Re: [CDO] Best Practices: how to save an CDObject with unsaved references [message #896329 is a reply to message #896266] Wed, 18 July 2012 01:14 Go to previous messageGo to next message
Eclipse UserFriend
Am 17.07.2012 21:39, schrieb Paco Blanco:
> In my case, I need to create a "complex" graph object model from scratch. For example, a country has localized names.
> Each localized name makes references to a language and a country so there are loops in the graph. In this example,
> these classes are connected logically by EMF EReference links.
>
> When I call to a service to persist one country from the model by CDO client, this service does know nothing if other
> ereferences associated entities are yet saved into a resource or not. So if service adds the country to a resource and
> does commit, an exception could be thrown because some of the associated entities are not included in any resource.
This is the DanglingReferenceException and it is being thrown in exactly this situation. Note that this situation is
detected on the client-side even before the repository is contacted for the commit.

> Is the situation to try to persist only one country a bad practice?
I can not judge it. I would probably prefer to fix the situation before I call commit, possibly with the help of
org.eclipse.emf.cdo.transaction.CDOAutoAttacher.

> What is the best practice to persist the graph model?
Not sure if a *best* practice exists. Maybe others want to add to the discussion.

> Does CDO provide a method to include "automatically" ereference linked objects that are not yet included into any
> resource?
See the CDOAutoAttacher I mentioned above ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Best Practices: how to save an CDObject with unsaved references [message #896330 is a reply to message #896329] Wed, 18 July 2012 01:17 Go to previous message
Eclipse UserFriend
Am 18.07.2012 07:14, schrieb Eike Stepper:
> See the CDOAutoAttacher I mentioned above.
Note that you can override the persist() method to control *where* it attaches the dangling objects.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Previous Topic:[CDO] Unique Contraint in Eattribute Objects
Next Topic:[CDO] Incorrect Management of Null EEnum Objects
Goto Forum:
  


Current Time: Sat Jul 05 07:21:41 EDT 2025

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

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

Back to the top