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.  [ 2 posts ] 
Author Message
 Post subject: cascade delete a child object with a one-to-one relationship
PostPosted: Wed Mar 28, 2007 7:50 am 
Newbie

Joined: Sat Sep 03, 2005 4:10 am
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
1.0.2

Mapping documents:
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="ClassA">
    <id name="Id" type="Int32">
      <generator class="native" />
    </id>
    <one-to-one name="B" cascade="all-delete-orphan"/>
  </class>

  <class name="ClassB">
   <id name="Id" type="Int32">
   <generator class="foreign">
      <param name="property">A</param>
   </generator>
   </id>
    <one-to-one name="A" constrained="true" />
  </class>
</hibernate-mapping>


The problem i am having is this:
Code:
ClassA A = new ClassA();


save, works fine

Code:
A.B = new ClassB();
B.A = A;


save, works fine

Code:
A.B = null;


save.
i would expect (hope !) that the ClassB object would be removed from the database. However, the next time i load object A, it has reappeared.

i'm sure i am missing something very simple, so any help would be gratefully received.

thanks,
mike.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 12:34 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
nope, you'd need to delete B before you save A. B still holds an association to A.

-d


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

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.