Hi,
I have 5 or 6 tables all with created by/updated by associations to my table of users. When I delete a user, I'd like to replace all these associations with "null". In other words, if the Product(mapping below) has a many-to-one relationship with User, when the User record is deleted I'd like the Product.created_user and Product.updated_user fields to become null.
What's the easiest way to do this? Is there something clever I can do with an inverse cascaded mapping to make this happen automagically?
I've read the parent/child docs (numerous times), and find the all-delete-orphan cascade works great for most situations (in the inverse relationship), but here I just want to clear the association, not delete the child records.
Thanks, WILL
Code:
<class name="Product" table="product" >
<meta attribute="generated-class">base.Product</meta>
<id name="product_id" column="product_id" type="long">
<generator class="increment"/>
</id>
<property name="name" type="string"/>
<property name="type" type="string"/>
<property name="last_updated" type="timestamp">
<column name="update_date" sql-type="DATETIME"/>
</property>
<property name="created" type="timestamp">
<column name="creation_date" sql-type="DATETIME"/>
</property>
<many-to-one name="created_user" column="creation_by" class="User" outer-join="true"/>
<many-to-one name="updated_user" column="update_by" class="User" outer-join="true"/>
</class>