-->
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: how to cascade delete to a joined-subclass ?
PostPosted: Thu Jun 29, 2006 5:04 pm 
Newbie

Joined: Thu Jun 29, 2006 4:39 pm
Posts: 3
Hello,

i used the table-per-subclass strategy to map inheritance.

Now, i would like to have the table rows of the subclass tables deleted when deleting an object from the parent class table.

Is this possible by adding a cascade-attribute to the mapping ?
Where should this attribute go ?

I only found documentation/examples for using cascade with sets etc.

The mapping looks as follows:

Code:
  <class name="Component" table="component">
    <id name="Id" type="java.lang.Integer">
      <column name="id"/> 
      <generator class="increment"/>
    </id> 
    <property name="Document" type="java.lang.Integer" insert="false" update="false">
      <column name="document" length="5" not-null="false"/>
    </property> 
    <property name="Position" type="java.lang.Integer">
      <column name="position" length="5" not-null="false"/>
    </property> 
    <many-to-one name="Fk_document" class="Document" property-ref="propfk_document">
      <column name="document" not-null="false"/>
    </many-to-one>
   
     <joined-subclass name="Article" table="article">
        <key column="id"/>
        <property name="Title" type="java.lang.String">
            <column name="title" length="200" not-null="false"/>
          </property> 
          <property name="Author" type="java.lang.String">
            <column name="author" length="200" not-null="false"/>
          </property> 
     </joined-subclass>
    
     <joined-subclass name="Text" table="text">
        <key column="id"/>
        <property name="Text" type="java.lang.String">
            <column name="text" length="2000" not-null="false"/>
          </property>
     </joined-subclass>
    
  </class>
</hibernate-mapping>


As one can see, i have a 'Document' Object which consists of 'Components' which can either be 'Article' or 'Text'.

The entries in the component table are deleted when deleting the document they belong to, but the article and text tables remain unchanged.

Thanks in advance.


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.