Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [teneo] delete not the references
[teneo] delete not the references [message #503647] Tue, 15 December 2009 03:39 Go to next message
Allon Moritz is currently offline Allon MoritzFriend
Messages: 38
Registered: July 2009
Member
an object A has a reference to object B which does have a reference to object C.
when I call A.setB(null) the object B is deleted in the database. so far so good but then teneo(hibernate) tries to delete object C as well.
how can I prevent that C is deleted? I saw some information on the net that I have to change some cascade options. but where in emf do I have to apply this changes?

an instruction for a newbie would help me a lot.....
Re: [teneo] delete not the references [message #503665 is a reply to message #503647] Tue, 15 December 2009 09:16 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Allon,
I am not sure if the association from B to C is a containment relation. If so then the delete seems logical.

There are two general options to control cascade behavior on associations:
PersistenceOptions.CASCADE_POLICY_ON_NON_CONTAINMENT
PersistenceOptions.CASCADE_POLICY_ON_CONTAINMENT
See:
http://www.elver.org/hibernate/options.html

You can also control the cascade per association using a JPA annotation in the model.
http://www.elver.org/hibernate/ejb3_format.html
http://www.elver.org/hibernate/ejb3_examples.html

Depending if it is a list or a single association you should use a @OneToMany or a @ManyToOne annotation (the examples:
ToOneAction and CascadeNotAllAction in the above examples link)

gr. Martin

Allon Moritz wrote:
> an object A has a reference to object B which does have a reference to
> object C.
> when I call A.setB(null) the object B is deleted in the database. so far
> so good but then teneo(hibernate) tries to delete object C as well.
> how can I prevent that C is deleted? I saw some information on the net
> that I have to change some cascade options. but where in emf do I have
> to apply this changes?
>
> an instruction for a newbie would help me a lot.....


--

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
Previous Topic:[CDO] Using 3.0
Next Topic:[CDO] 2.0 / 3.0 compatibility
Goto Forum:
  


Current Time: Fri Apr 26 05:35:04 GMT 2024

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

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

Back to the top