-->
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: Cascades not working for parent/child relationship
PostPosted: Thu May 19, 2005 7:52 pm 
Senior
Senior

Joined: Tue Mar 02, 2004 6:17 pm
Posts: 151
Hibernate version: 3.0.3

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.be.desktopbeautifier.server">
  <class name="ThemeHibernate" table="theme">
    <id name="id" unsaved-value="0">
      <generator class="assigned"/>
    </id>
    <discriminator column="class"/>
    <version name="version"/>
   
    <property name="name" type="java.lang.String" not-null="true"/>   
   
    <set name="children" cascade="all-delete-orphan" sort="unsorted"
    inverse="true">
      <key>
        <column name="parent_id"/>
      </key>     
      <one-to-many class="ThemeHibernate"/>
    </set>

    <many-to-one name="parent" column="parent_id" class="ThemeHibernate"
    cascade="all"/>

    <subclass name="com.be.desktopbeautifier.server.DefaultTheme"/>
  </class>
</hibernate-mapping>



I have a parent/child relationship as mentioned in the document. The problem is that if I create a Parent, invoke Parent.add(Child), then Session.save(parent) the save() operation is not being cascaded to the child. This is a special case because I am using assigned identifiers but the documentation says this *should* work nontheless, yet it does not.

Any ideas?

Gili


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.