hibernate: how to setup on-delete="cascade" in one-to-one relation
i have to table relation one-to-one: message & scheduled_message
my hibernate config
<class name="Message" table="message">
<id name="id" column="id">
<generator class="native" />
</id>
<property name="name" column="name" />
&开发者_开发百科lt;one-to-one name="scheduled">
</class>
<class name="ScheduledMessage" table="scheduled_message">
<id name="id" column="id">
<generator class="native" />
</id>
<property name="startTime" column="start_time" />
<property name="stopTime" column="stop_time" />
<many-to-one name="message" column="message_id"
unique="true" not-null="true" />
</class>
i want when message is deleted, scheduled_message is deleted too, but i dont know how to add on-delete="cascade" to this relation.
please help me
thanks
Quan
Hibernate docs say that <one-to-one>
supports the cascade
atribute. So:
<one-to-one name="scheduled" cascade="delete" .... />
精彩评论