-->
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.  [ 3 posts ] 
Author Message
 Post subject: SchemaUpdate many-to-one cascade delete mapping
PostPosted: Tue Jan 30, 2007 10:27 am 
Beginner
Beginner

Joined: Mon Jan 22, 2007 1:16 pm
Posts: 21
I am trying to use this mapping from the HelloWorld tutorial.

<many-to-one name="nextMessage"
cascade="all"
column="NEXT_MESSAGE_ID"
foreign-key="FK_NEXT_MESSAGE"/>

The complete mapping is pasted below. The problem that I have is that the DB that I am using (SQLBase) gives me the following error:

"Self-reference foreign key must have CASCADE delete rule "

If I change cascade="all" to cascade="delete", I still get the same error.

Is there a way to enable cascade delete when using the many-to-one mapping? Ultimately, i am looking for a way to have hbm2ddl generate "on delete cascade" at the end of the sql it uses to create the foreign key.

Thanks for any help.
-Mark


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class
name="hello.Message"
table="MESSAGES">
<id
name="id"
column="MESSAGE_ID">
<generator class="increment"/>
</id>
<property
name="text"
column="MESSAGE_TEXT"/>
<many-to-one
name="nextMessage"
cascade="all"
column="NEXT_MESSAGE_ID"
foreign-key="FK_NEXT_MESSAGE"/>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 1:03 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi ,izzbananafrance

Why you want to delete parent. Because parent is associated with other child and you have only one reference of child from that reference you want to delete it.It is conceptually wrong. Even in Data Base with out removing the reference of parent you can not delete parent

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 31, 2007 12:03 pm 
Beginner
Beginner

Joined: Mon Jan 22, 2007 1:16 pm
Posts: 21
the mapping comes from the HelloWorld tutorial. I am just trying to get it to work with SQLBase.

When I try, i get a "Self-reference foreign key must have CASCADE delete rule "

No big deal really since it is a mapping from the tutorial and not something I came up with on my own.

thanks for the response!

-mark


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.