title: JPA relationship not getting updated when children are removed
body: <p>Given the following scenario:</p>
  
  <pre><code>@Entity
  public class A {
    @OneToMany(mappedBy = "a", cascade = CascadeType.ALL)
    private List&lt;B&gt; bList;
  }
  
  @Entity
  public class B {
    @ManyToOne()
    @JoinColumn(name = "a_id", referencedColumnName = "id")
    private A a;
  
    @ManyToOne()
    @JoinColumn(name = "c_id", referencedColumnName = "id")
    private C c;
  }
  
  @Entity
  public class C {
    @OneToMany(mappedBy="c", cascade=CascadeType.ALL, orphanRemoval=true)
    @CascadeOnDelete // eclipselink specific optimization annotation
    private List&lt;B&gt; bList;
  }
  </code></pre>
  
  <p>In other words: both object A and object C contains a number of B objects.</p>
  
  <p>When I remove a C object (technically, I am updating an object containing several C objects and using orphanremoval), I wish to remove all referenced B-objects, which works as expected with current annotations. However, the Entity manager doesn't seem to understand that object A lying in its cache now have lost some children. If I had an instance of A, I would of course have to update its bList manually, or do a new query to update it, but even newly fetched A-objects are still outdated. To reiterate:</p>
  
  <ul>
  <li>C objects are removed.</li>
  <li>Removal is cascaded to B objects with orphanRemoval.</li>
  <li>bList in A objects cached in Entity Manager is <strong>not updated</strong>.</li>
  <li>Manually purging Entity Managers cache makes it retrieve properly updated objects.</li>
  </ul>
  
  <p>How can this be solved? I would expect either the entity managers to update its persistence context automatically, or making a cascade annotation available on @JoinColumn, but neither seems to be the case here.</p>
  
  <p><strong>EDIT: It seems that the problem lies in object C's bList not getting updated when object A's bList is updated (and thus cannot cascade changes). I have no idea why though.. Still note that I'm talking about the persistance context and not instantiated objects.</strong></p>