-->
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: want on-delete="cascade" syntax <one-to-one>
PostPosted: Tue Oct 10, 2006 2:18 pm 
Regular
Regular

Joined: Tue Mar 21, 2006 11:01 am
Posts: 65
Hibernate version: 3.0.5

In Hibernate 3.0.5 is there any way to do a mapping between class A and B such that on-delete="cascade" functionality (in Oracle "ON DELETE CASCADE ENABLE") is generated in the DDL?

It would not appear to be so, since on-delete is an attribute of a <key> and <key> is not legal for <one-to-one>, unlike the situation with other forms of association (there is no collection here on either side).

Is there a workaround for this? Here is what I have. I want the generated SQL to add ON DELETE CASCADE ENABLE on B's foreign key constraint to A.


Code:
<hibernate-mapping>
   <class name="A">
      <id name="id" type="java.lang.Long"column="a_id">
         <generator class="seqhilo">
            <param name="max_lo">100</param>
            <param name="sequence">a_seq</param>
         </generator>
      </id>
      
      <one-to-one name="myB"
         class="B"
         property-ref="myA"
         lazy="true"
         fetch="select">
      </one-to-one>

      <!-- other data -->

   </class>
   <class name="B">
      <id name="id" type="java.lang.Long" column="id">
         <generator class="seqhilo">
            <param name="max_lo">100</param>
            <param name="sequence">_seq</param>
         </generator>
      </id>
      
      <many-to-one name="myA"
         column="A_id"
         unique="true"
         not-null="true"/>

           <!-- other data -->
         
   </class>
   
</hibernate-mapping>




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.