title: JPA CascadeType.REMOVE not working
body: <p>I have two entities <em>Business</em> which is composed of a list of <em>Departments</em></p>
  
  <pre><code>@Entity
  @Table(name = "Business")
  public class Business implements Serializable {
  
    private static final long serialVersionUID = 1L;
  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "Id")
    private Long id;
  
    @OneToMany(mappedBy = "business", 
         cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
     private List&lt;Department&gt; departments;
  
     @OneToMany(mappedBy = "business", orphanRemoval = true, 
       cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
     private List&lt;Process&gt; processs;
  
     @ManyToMany
     private List&lt;Competence&gt; competences;
  }
  
  
  @Entity
  @Table(name = "Department")
  public class Department implements Serializable {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     private Long id;
  
     @OneToMany(mappedBy = "father", 
          cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
     private List&lt;Department&gt; departments;
  }
  </code></pre>
  
  <p>When I try to remove a business instance I get a Mysql Exception</p>
  
  <p><em>Cannot delete or update a parent row: a foreign key constraint fails (<code>evac_java</code>.<code>Department</code>, CONSTRAINT <code>FK_Department_Business</code> FOREIGN KEY (<code>Business</code>) REFERENCES <code>Business</code> (<code>Id</code>)):HY000 - null</em></p>
  
  <p>Which means I can't delete the business instance because it has departments associated with it, but a department cannot exists by itself so I want to delete all business's departments when it gets removed. I thought I would achieve this by adding cascade = CascadeType.REMOVE to the @OneToMany annotation in the business entity, but it does not work.</p>
  
  <p>I did a search on the net and I found a lot of questions similar to this one on stackoverflow but they all suggest the same: <em>add cascade = CascadeType.REMOVE or CascadeType.ALL</em></p>
  
  <p>So I'm wondering if I'm missing somethig.</p>
  
  <p>I'm using Glassfish 4.1 and EclipseLink</p>
  
  <p>I tried with </p>
  
  <pre><code>@OneToMany(mappedBy = "business", orphanRemoval = true)
  private List&lt;Department&gt; departments;
  </code></pre>
  
  <p>on the business entity but it does not work either</p>
  
  <p>Here's the method I'm using to remove entities which is declared in an abstract class</p>
  
  <pre><code>public void remove(T entity) {
      getEntityManager().remove(getEntityManager().merge(entity));
  }
  </code></pre>