Home » Modeling » EMF » [Teneo] Contained eObject referenced by another eObject?
|
Re: [Teneo] Contained eObject referenced by another eObject? [message #424545 is a reply to message #424531] |
Wed, 29 October 2008 19:45 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Liviu,
The answer on your question is yes it is possible to have references between two contained objects.
The default cascade for containment is ALL which also includes delete-orphan. So I think not setting
this option is the right approach. Then when Budget is deleted also its budgetlines are deleted and
when removing a budgetline from budget, the budgetline will be removed.
Regarding your exception. Looking at the stacktrace I think the following happened:
there is a reference from budgetline to an indicator, the indicator gets deleted (I am not sure
why), which is not possible because the budgetline refers ot it.
So the question is why the indicator gets deleted.
gr. Martin
Liviu wrote:
> Hi
>
> I've got this scenario:
> Budget, BudgetLine, SetInicator, Indicator are all EObjects.
>
>
> A Budget has a list of BudgetLine's. "budget.getBudgetLines" gives the
> list of BudgetLine's. This reference is an explicit containment
> (Cotainment = true)
>
> The same goes for SetIndicator and Indicator, meaning that SetIndicator
> has a list of Indicator's with a "Containment=true" reference.
>
>
> Budget has a simple reference (not a list and not a containment) for a
> SetIndicator (budget.getSetIndicator).
>
> BudgetLine has a simple reference(not a list and not a containment) for
> an Indicator.
>
>
> When I try to save a Budget I get the exception attached in case1.txt.
>
> CASE 2: If I put:
> CASCADE_POLICY_ON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" then
> saving works but deleting a Budget won't work - I suppose I should
> manually delete BudetLines but then again it's not practical 'cause I
> should change too much.
> Yet another trick in this case is that apparently the Indicator looses
> its relation to the SetIndicator in that it is no longer contained in it.
>
> NOTE: SET_CASCADE_ALL_ON_CONTAINMENT is not set in neither cases.
>
>
> Question: Can a contained eObject (Indicator whitch s contained by
> SetIndicator) be referenced from another eObject (BudgetLine whitch
> itself is contained by Budget) without changing the relationship between
> the Indicator and the SetIndicator?
>
>
> Many thanks
> Liviu
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Re: [Teneo] Contained eObject referenced by another eObject? [message #424547 is a reply to message #424545] |
Wed, 29 October 2008 20:10 |
Liviu-Marian Negrila Messages: 53 Registered: July 2009 |
Member |
|
|
Hi Martin,
Thanks - I will reanalyze I might have omitted something.
I think your assumption is correct in regards to the deletion of the
Indicator - looking at the consoleLog I did see that the
hibernateResource.save tried to delete it and I thought that it was
related to the containment - hence my initial post. It was not included
in the removedEObjects list from HibernateResource.saveResource though.
I'll be back should I find a solution next 6 hours otherwise I will
condiser a model change and when I get the time I will try producing a
testcase for this.
Until then please accept the symbol of my deepest consideration,
Liviu
Martin Taal wrote:
> Hi Liviu,
> The answer on your question is yes it is possible to have references
> between two contained objects.
>
> The default cascade for containment is ALL which also includes
> delete-orphan. So I think not setting this option is the right approach.
> Then when Budget is deleted also its budgetlines are deleted and when
> removing a budgetline from budget, the budgetline will be removed.
>
> Regarding your exception. Looking at the stacktrace I think the
> following happened:
> there is a reference from budgetline to an indicator, the indicator gets
> deleted (I am not sure why), which is not possible because the
> budgetline refers ot it.
> So the question is why the indicator gets deleted.
>
> gr. Martin
>
> Liviu wrote:
>> Hi
>>
>> I've got this scenario:
>> Budget, BudgetLine, SetInicator, Indicator are all EObjects.
>>
>>
>> A Budget has a list of BudgetLine's. "budget.getBudgetLines" gives the
>> list of BudgetLine's. This reference is an explicit containment
>> (Cotainment = true)
>>
>> The same goes for SetIndicator and Indicator, meaning that SetIndicator
>> has a list of Indicator's with a "Containment=true" reference.
>>
>>
>> Budget has a simple reference (not a list and not a containment) for a
>> SetIndicator (budget.getSetIndicator).
>>
>> BudgetLine has a simple reference(not a list and not a containment) for
>> an Indicator.
>>
>>
>> When I try to save a Budget I get the exception attached in case1.txt.
>>
>> CASE 2: If I put:
>> CASCADE_POLICY_ON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" then
>> saving works but deleting a Budget won't work - I suppose I should
>> manually delete BudetLines but then again it's not practical 'cause I
>> should change too much.
>> Yet another trick in this case is that apparently the Indicator looses
>> its relation to the SetIndicator in that it is no longer contained in it.
>>
>> NOTE: SET_CASCADE_ALL_ON_CONTAINMENT is not set in neither cases.
>>
>>
>> Question: Can a contained eObject (Indicator whitch s contained by
>> SetIndicator) be referenced from another eObject (BudgetLine whitch
>> itself is contained by Budget) without changing the relationship between
>> the Indicator and the SetIndicator?
>>
>>
>> Many thanks
>> Liviu
>>
>
>
|
|
|
Re: [Teneo] Contained eObject referenced by another eObject? [message #425366 is a reply to message #424547] |
Sat, 22 November 2008 17:34 |
Liviu-Marian Negrila Messages: 53 Registered: July 2009 |
Member |
|
|
Hi Martin,
I did not have to change the model.
It seemed that it was a problem becous I used one session to create the
object I wanted to save but some of its references were loaded through
another session.
Thanks again
Liviu
Liviu wrote:
> Hi Martin,
>
> Thanks - I will reanalyze I might have omitted something.
> I think your assumption is correct in regards to the deletion of the
> Indicator - looking at the consoleLog I did see that the
> hibernateResource.save tried to delete it and I thought that it was
> related to the containment - hence my initial post. It was not included
> in the removedEObjects list from HibernateResource.saveResource though.
>
> I'll be back should I find a solution next 6 hours otherwise I will
> condiser a model change and when I get the time I will try producing a
> testcase for this.
>
> Until then please accept the symbol of my deepest consideration,
> Liviu
>
> Martin Taal wrote:
>> Hi Liviu,
>> The answer on your question is yes it is possible to have references
>> between two contained objects.
>>
>> The default cascade for containment is ALL which also includes
>> delete-orphan. So I think not setting this option is the right approach.
>> Then when Budget is deleted also its budgetlines are deleted and when
>> removing a budgetline from budget, the budgetline will be removed.
>>
>> Regarding your exception. Looking at the stacktrace I think the
>> following happened:
>> there is a reference from budgetline to an indicator, the indicator gets
>> deleted (I am not sure why), which is not possible because the
>> budgetline refers ot it.
>> So the question is why the indicator gets deleted.
>>
>> gr. Martin
>>
>> Liviu wrote:
>>> Hi
>>>
>>> I've got this scenario:
>>> Budget, BudgetLine, SetInicator, Indicator are all EObjects.
>>>
>>>
>>> A Budget has a list of BudgetLine's. "budget.getBudgetLines" gives the
>>> list of BudgetLine's. This reference is an explicit containment
>>> (Cotainment = true)
>>>
>>> The same goes for SetIndicator and Indicator, meaning that SetIndicator
>>> has a list of Indicator's with a "Containment=true" reference.
>>>
>>>
>>> Budget has a simple reference (not a list and not a containment) for a
>>> SetIndicator (budget.getSetIndicator).
>>>
>>> BudgetLine has a simple reference(not a list and not a containment) for
>>> an Indicator.
>>>
>>>
>>> When I try to save a Budget I get the exception attached in case1.txt.
>>>
>>> CASE 2: If I put:
>>> CASCADE_POLICY_ON_CONTAINMENT = "REMOVE,REFRESH,PERSIST,MERGE" then
>>> saving works but deleting a Budget won't work - I suppose I should
>>> manually delete BudetLines but then again it's not practical 'cause I
>>> should change too much.
>>> Yet another trick in this case is that apparently the Indicator looses
>>> its relation to the SetIndicator in that it is no longer contained in it.
>>>
>>> NOTE: SET_CASCADE_ALL_ON_CONTAINMENT is not set in neither cases.
>>>
>>>
>>> Question: Can a contained eObject (Indicator whitch s contained by
>>> SetIndicator) be referenced from another eObject (BudgetLine whitch
>>> itself is contained by Budget) without changing the relationship between
>>> the Indicator and the SetIndicator?
>>>
>>>
>>> Many thanks
>>> Liviu
>>>
>>
|
|
|
Goto Forum:
Current Time: Tue Sep 24 23:23:11 GMT 2024
Powered by FUDForum. Page generated in 0.04242 seconds
|