title: Hibernate bi-directional many-to-many cascade confusion
body: <p>I'm a hibernate newbie and I'm not entirely sure how to get the cascade behavior I'm looking for.</p>
  
  <p>Let's say I have two classes A and B with bi-directional many-to-many mappings to each other. A is the owner side and B is the inverse side (I hope I have the terminology correct).</p>
  
  <pre><code>public class A
  {
      private Set&lt;B&gt; bSet = new HashSet&lt;B&gt;();
  
      @ManyToMany(targetEntity=B.class, cascade=CascadeType.?)
      public Set&lt;B&gt; getBSet()
      {
          return bSet;
      }
  }
  
  public class B
  {
      private Set&lt;A&gt; aSet = new HashSet&lt;A&gt;();
  
      @ManyToMany(mappedBy="bSet", targetEntity=A.class, cascade=CascadeType.?)
      public Set&lt;B&gt; getBSet()
      {
          return bSet;
      }
  }
  </code></pre>
  
  <p>I want to select the correct cascade type so that when I delete an A object, any B object containing it is updated and vice-versa.</p>
  
  <p>Which cascade type(s) do I need here?</p>