Hello,
I've just started using Hibernate and have come across a small problem. I have a class RouteSet, which contains a Set of class Route (defined as a one-to-many relationship).
When my app starts, I retrieve my RouteSet object from the database. My problem is this: If I then reassign the underlying set reference using RouteSet.setRoute(Set<Route> newRoutes) and persist the object, any Route objects no longer in the Set are not deleted from the database; instead their foreign key is set to null.
I thought that setting cascade="all-delete-orphan" on RouteSet would fix this problem, but it doesn't appear to. Does anyone have any ideas?
Regards,
Adam.
Extract from RouteSet.hbm.xml:
Code:
<set name="routes" cascade="all-delete-orphan" lazy="false">
<key column="routeSetId" />
<one-to-many class="Route" />
</set>