[CDO] Best Practices: how to save a CDObject with unsaved references [message #896266] |
Tue, 17 July 2012 19:39 |
Paco Blanco Messages: 28 Registered: June 2012 |
Junior Member |
|
|
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 20:13] Report message to a 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 05:14 |
|
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
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
Powered by
FUDForum. Page generated in 0.02190 seconds