I have a 1-1 relation between two classes, ManageableEvent and Location, with ManageableEvent containing Location. The mapping is like this.
Code:
<class name="ManageableEvent" table="manageable_events">
<id name="id" type="UUID">
<column name="manageble_event_id" sql-type="char(36)"/>
<generator class="UUIDGenerator"/>
</id>
<many-to-one class="Location" name="location" cascade="all">
<column name="location_id" sql-type="char(36)"/>
</many-to-one>
</class>
<class name="Location" table="locations">
<id name="id" type="UUID">
<column name="location_id" sql-type="char(36)"/>
<generator class="UUIDGenerator"/>
</id>
</class>
I have a ManageableEvent object with a Location object contained in it. When I save it, one row is created in manageable_events table with a location_id value that corresponds to one row in the locations table.
Now in some other tier, I replace the Location instance contained in teh ManageableEvent to some other new Location object. Now if I save this ManageableEvent, the row in manageable_events table is updated with the new location_id that corersponds to the new row in the locations table.
My question is what happens to the old Location entry in the locations table that was related to the ManageableEvent before. Do I have to explicitly delete that row or is there some way in the mapping that I can take care of deleting that "orphaned" row in the locations table.
Thanks