Let's say I have two classes, Resource and User and every resource has an owner (which is an instance of User). This can be easily done with a many-to-one association from Resource to User like this:
Code:
<hibernate-mapping>
<class name="Resource" table="resources">
<id [...]/>
<many-to-one name="owner" class="User"
cascade="none" not-null="true"/>
</class>
</hibernate-mapping>
Now when it comes to deleting a user all resources that refer to that user have to be deleted manually. Otherwise the 'not-null' constraint gets violated and the database is broken.
So, can Hibernate somehow remove the resources automatically? That would require a 'cascade' that work the other way around and propagates the operation from User to Resource.
Any help would be appreciated.
Markus