title: Automatically remove deleted entity from all collections referencing it
body: <p>Is it possible, when using Hibernate and cascade delete, to remove the cascade-deleted entity from all other entities that have a reference to it? </p>
  
  <p>Take this diagram for example:</p>
  
  <p><a href="https://i.stack.imgur.com/pS7Cl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pS7Cl.png" alt="enter image description here"></a></p>
  
  <p><code>User</code> has a <code>MembershipOffer</code> to join a <code>Group</code>. In my model is possible to remove groups with pending offers, and when that happens, I want all the offers of the deleted group to be deleted as well.</p>
  
  <p>I understand that in order to do that, I will need to change the <code>MembershipOffer-Group</code> association to be bidirectional and set the <code>cascade</code> flag on it. However, when MembershipOffer is deleted, what happens to the <code>User</code>'s reference to it? </p>
  
  <p>I assume Hibernate won't go through every reference to the deleted object and remove it from appropriate collections. Will I have to delete the references manually, or is there a automatic way to do it?</p>
  
  <p><strong>Note:</strong> 
  I am using a relational database and from purely SQL-based look I don't see a problem. <code>MembershipOffer</code> table contains FK of both User and Group. When Group is deleted, so are all Offers containing its FK. With their removal the link between Offer and User is deleted. The problem I have is that in the code <code>User</code> has a field <code>Set&lt;MembershipOffer&gt; membershipOffers</code> which may contain a reference to the just-deleted Offer (which will be invalid if I try to access it).</p>