Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » cascaded deletes
cascaded deletes [message #83414] Tue, 15 May 2007 14:54 Go to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
I have a model that is using annotated java. I have two classes, where
ClassA has a list of ClassB objects:

ClassA
- EList<ClassB>

When I delete an instance of ClassB, I have to also remove the instance from
ClassA's list of ClassB objects. I am pretty sure there is a way to do this
automatically, using an annotation, but I'm not sure how. Can anyone point
me in the right direction?
Re: cascaded deletes [message #83690 is a reply to message #83414] Wed, 16 May 2007 12:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Paul,

Is this a question about Teneo? What exactly do you mean by delete an
instance of ClassB? Are you using a DeleteCommand? In terms of direct
model manipulations, you never delete an object , you simply remove it
from the things that reference it and when all those references are
gone, it's garbage collected. That's what EcoreUtil.delete does...


Paul Gardiner wrote:
> I have a model that is using annotated java. I have two classes, where
> ClassA has a list of ClassB objects:
>
> ClassA
> - EList<ClassB>
>
> When I delete an instance of ClassB, I have to also remove the instance from
> ClassA's list of ClassB objects. I am pretty sure there is a way to do this
> automatically, using an annotation, but I'm not sure how. Can anyone point
> me in the right direction?
>
>
>
Re: cascaded deletes [message #83717 is a reply to message #83690] Wed, 16 May 2007 13:00 Go to previous messageGo to next message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
Sorry, I forgot to put teneo in the subject. Yes, it's a teneo problem. I
am doing a session.delete(classB), but I also have to go through and delete
any references to classB in any instances of ClassA. I figure that if I had
it set up properly, this would automagically delete all the references, but
I'm not sure how to set up a "join" using annotations.
"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f2esd7$k35$1@build.eclipse.org...
> Paul,
>
> Is this a question about Teneo? What exactly do you mean by delete an
> instance of ClassB? Are you using a DeleteCommand? In terms of direct
> model manipulations, you never delete an object , you simply remove it
> from the things that reference it and when all those references are gone,
> it's garbage collected. That's what EcoreUtil.delete does...
>
>
> Paul Gardiner wrote:
>> I have a model that is using annotated java. I have two classes, where
>> ClassA has a list of ClassB objects:
>>
>> ClassA
>> - EList<ClassB>
>>
>> When I delete an instance of ClassB, I have to also remove the instance
>> from ClassA's list of ClassB objects. I am pretty sure there is a way to
>> do this automatically, using an annotation, but I'm not sure how. Can
>> anyone point me in the right direction?
>>
>>
Re: cascaded deletes [message #83732 is a reply to message #83690] Wed, 16 May 2007 13:14 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Paul,
Your question is valid but I can not find the answer to it. In a previous time I have worked with
systems in which you can define that a foreign key should be nullified when a record is removed but
I do not know how to express this in hibernate.
So as far as I can see you would need to read all refers to B and remove B from the relevant lists
or clear references to B. The HbDataStore offers method to efficiently retrieve all referers to a
specific object. This can be of help.

Otherwise I would ask on the Hibernate forum. I am also interested in the answer.

gr. Martin

Ed Merks wrote:
> Paul,
>
> Is this a question about Teneo? What exactly do you mean by delete an
> instance of ClassB? Are you using a DeleteCommand? In terms of direct
> model manipulations, you never delete an object , you simply remove it
> from the things that reference it and when all those references are
> gone, it's garbage collected. That's what EcoreUtil.delete does...
>
>
> Paul Gardiner wrote:
>> I have a model that is using annotated java. I have two classes,
>> where ClassA has a list of ClassB objects:
>>
>> ClassA
>> - EList<ClassB>
>>
>> When I delete an instance of ClassB, I have to also remove the
>> instance from ClassA's list of ClassB objects. I am pretty sure there
>> is a way to do this automatically, using an annotation, but I'm not
>> sure how. Can anyone point me in the right direction?
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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: cascaded deletes [message #606709 is a reply to message #83414] Wed, 16 May 2007 12:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Paul,

Is this a question about Teneo? What exactly do you mean by delete an
instance of ClassB? Are you using a DeleteCommand? In terms of direct
model manipulations, you never delete an object , you simply remove it
from the things that reference it and when all those references are
gone, it's garbage collected. That's what EcoreUtil.delete does...


Paul Gardiner wrote:
> I have a model that is using annotated java. I have two classes, where
> ClassA has a list of ClassB objects:
>
> ClassA
> - EList<ClassB>
>
> When I delete an instance of ClassB, I have to also remove the instance from
> ClassA's list of ClassB objects. I am pretty sure there is a way to do this
> automatically, using an annotation, but I'm not sure how. Can anyone point
> me in the right direction?
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: cascaded deletes [message #606711 is a reply to message #83690] Wed, 16 May 2007 13:00 Go to previous message
Paul Gardiner is currently offline Paul GardinerFriend
Messages: 94
Registered: July 2009
Member
Sorry, I forgot to put teneo in the subject. Yes, it's a teneo problem. I
am doing a session.delete(classB), but I also have to go through and delete
any references to classB in any instances of ClassA. I figure that if I had
it set up properly, this would automagically delete all the references, but
I'm not sure how to set up a "join" using annotations.
"Ed Merks" <merks@ca.ibm.com> wrote in message
news:f2esd7$k35$1@build.eclipse.org...
> Paul,
>
> Is this a question about Teneo? What exactly do you mean by delete an
> instance of ClassB? Are you using a DeleteCommand? In terms of direct
> model manipulations, you never delete an object , you simply remove it
> from the things that reference it and when all those references are gone,
> it's garbage collected. That's what EcoreUtil.delete does...
>
>
> Paul Gardiner wrote:
>> I have a model that is using annotated java. I have two classes, where
>> ClassA has a list of ClassB objects:
>>
>> ClassA
>> - EList<ClassB>
>>
>> When I delete an instance of ClassB, I have to also remove the instance
>> from ClassA's list of ClassB objects. I am pretty sure there is a way to
>> do this automatically, using an annotation, but I'm not sure how. Can
>> anyone point me in the right direction?
>>
>>
Re: cascaded deletes [message #606712 is a reply to message #83690] Wed, 16 May 2007 13:14 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Paul,
Your question is valid but I can not find the answer to it. In a previous time I have worked with
systems in which you can define that a foreign key should be nullified when a record is removed but
I do not know how to express this in hibernate.
So as far as I can see you would need to read all refers to B and remove B from the relevant lists
or clear references to B. The HbDataStore offers method to efficiently retrieve all referers to a
specific object. This can be of help.

Otherwise I would ask on the Hibernate forum. I am also interested in the answer.

gr. Martin

Ed Merks wrote:
> Paul,
>
> Is this a question about Teneo? What exactly do you mean by delete an
> instance of ClassB? Are you using a DeleteCommand? In terms of direct
> model manipulations, you never delete an object , you simply remove it
> from the things that reference it and when all those references are
> gone, it's garbage collected. That's what EcoreUtil.delete does...
>
>
> Paul Gardiner wrote:
>> I have a model that is using annotated java. I have two classes,
>> where ClassA has a list of ClassB objects:
>>
>> ClassA
>> - EList<ClassB>
>>
>> When I delete an instance of ClassB, I have to also remove the
>> instance from ClassA's list of ClassB objects. I am pretty sure there
>> is a way to do this automatically, using an annotation, but I'm not
>> sure how. Can anyone point me in the right direction?
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
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
Previous Topic:how to paging big model and still reserve EMF.Edit command framework?
Next Topic:TENEO - need multi-tiered environment solution
Goto Forum:
  


Current Time: Fri Apr 19 11:45:58 GMT 2024

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

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

Back to the top