Quote:
But, when i do parent.getChildren().remove(child) and save the parent the child record is not removed.
Well, I'm just thinking about it logically. If you remove the child from the parent, the association is gone, but does that imply the child should be deleted? It's like divorcing your wife. You can kill the relationship, but that doesn't kill her. Ok, bad analogy, but you know what I mean.
I'm wondering if you checked the parent if you would see the association removed, that is, the foreign key nulled.
What effect would cascade-delete-orphan have on this effect? Have you given that a shot?
Quote:
You can even use cascade="all" to specify that all operations should be cascaded along the association. The default cascade="none" specifies that no operations are to be cascaded.
A special cascade style, delete-orphan, applies only to one-to-many associations, and indicates that the delete() operation should be applied to any child object that is removed from the association.
Recommendations:
It does not usually make sense to enable cascade on a <many-to-one> or <many-to-many> association. Cascade is often useful for <one-to-one> and <one-to-many> associations.
If the child object's lifespan is bounded by the lifespan of the parent object, make it a life cycle object by specifying cascade="all,delete-orphan".
Otherwise, you might not need cascade at all. But if you think that you will often be working with the parent and children together in the same transaction, and you want to save yourself some typing, consider using cascade="persist,merge,save-update".
http://docs.jboss.org/hibernate/stable/core/reference/en/html/objectstate.html