-->
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: newbie Collections question!
PostPosted: Thu Nov 06, 2003 10:20 pm 
Beginner
Beginner

Joined: Thu Nov 06, 2003 10:04 pm
Posts: 22
I have a mapping as follows
Code:
<class name="Parent" table="parents">

  <key>
      <column name="parent_id", sql-type="char(36)"/>
  </key>

  <list name="children" cascade="all">
       <key>
           <column name="parent_id" sql-type="char(36)"/>
       </key>
       <index column="index"/>
       <one-to-many class="Child"/>
  </list>

</class>

<class name="Child" table="children">

   <key>
       <column name="child_id" sql-type="char(36)"/>
   </key>

</class>

Now I have a Parent object with some Child objects contained in it. If I do a Parent.getChildren().clear(), then I wanted to know if all the associated entries in the children table deleted?

It doesnt seem to do so in my code. I am trying to get the semantics of collections right. This mapping is supposed to be a one-to-many from Parent to Child, with all operations on Parent cascaded onto Child, but not vice-versa.

Or do I have to manually delete each Child entry apart from doing the Parent.getChildren().clear()? If this is the case, is there a way I can avoid this by some means in the mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 06, 2003 10:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, you must use cascade="all-delete-orphan", as per the doco.


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.