-->
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: Cascade delete unidirectional optional one-to-one
PostPosted: Tue Mar 05, 2013 11:22 am 
Newbie

Joined: Mon Jan 31, 2011 11:22 pm
Posts: 6
Code:
<hibernate-mapping>
   <class name="Document" table="document">
      ......

      <join table="Document_Meta" optional="true" >
         <key column="Document_Id" />
         <many-to-one name="meta" column="Meta_Id" not-null="true" unique="true" cascade="all-delete-orphan" />
      </join>

   </class>
</hibernate-mapping>


<hibernate-mapping>
   <class name="Meta" table="meta">
      <id name="id" type="int">
         <column name="Id" />
         <generator class="identity" />
      </id>
      <set name="articles" cascade="all,delete-orphan" fetch="join">
         <key column="Meta_Id" />
         <one-to-many class="Article" />
      </set>
      ..........
   </class>
</hibernate-mapping>


<hibernate-mapping>
   <class name="Article" table="article">
      <id name="id" type="int">
         <column name="Id" />
         <generator class="identity" />
      </id>

      <many-to-one class="Meta" name="meta" update="false" insert="false" />

   </class>
</hibernate-mapping>



When I delete a document I would like to delete the associated meta and article(s). How would I go about doing this? Right now it just deletes the
entry in the join table Document_Meta and keeps the rows in Meta and Article.


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.