garylam wrote:
I have a one to one relationship in my database.
UserTable
------------
UID
UserName
...
SecurityTable
SID
Name
...
In which UID is one to one mapping to SID
When I deleting row in UserTable I want it cascade on delete the SecurityTable row as well.
Can anyone give me some hints?
Here is bit in the mapping file that I am using. Appearanely its not working
<set
name="SecurityUser"
lazy="true"
inverse="true"
cascade="all-delete-orphan"
access="field.camelcase-underscore"
>
<key>
<column name="SID" />
</key>
<one-to-many
class="Domain.User, Security"
/>
</set>
If its a one-to-one relationship, then you shouldn't have a 'set' or one-to-many in the mapping file. The PK of the Parent Table should be related to the Parent Key of the Child table in a One-To-One relationship.
One-To-One Explained here:
http://www.hibernate.org/hib_docs/nhibe ... n-onetoone
AFAIK, you'll need to fix your mappings, then follow the directions here to Cascade delete:
http://www.hibernate.org/hib_docs/nhibe ... a-deleting