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>
|
|