-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Cascading set to none, still tries to delete
PostPosted: Fri May 25, 2007 8:53 am 
Newbie

Joined: Fri Dec 01, 2006 11:23 am
Posts: 2
I have three structures that I have to work with. An AgencyContact, OfficerContact and an Officer.

AgencyContact has a one-to-many relationship with OfficerContact.
OfficerContact has a many to one relationship with Officer.

AgencyContact.hbm.xml part for officercontact is


Code:
<bag name="officerContacts" lazy="false" cascade="all-delete-orphan" inverse="true">
        <key column="AGENCY_CONTACT_ID"/>
       <one-to-many class="OfficerContact"/>
   </bag>


OfficerContact.hbm.xml


Code:
<many-to-one name="officer"
         class="Officer"
         column="OFFICER_ID"
         cascade="none"     
         lazy="false" />


Here's the very weird part. When I delete an agencyContact, it tries to delete an Officer. This fails because other objects are referencing that Officer.

So, am I just not understanding what cascade="none" is? I thought it was basically me telling Hibernate "worry about the relationships (fill in the FK when necessary), but don't actually try to insert/update/delete when it comes to the Officer".

As for the code, the issue might be that I'm first getting the AgencyContact and then (using Spring's hibernateTemplate class) passing that object into a generic delete method. But I'm not exactly sure why that would cause a problem. The getting and the deleting of the object are in the same hibernate session.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.