title: JPA cascading delete for foreign key
body: <p>I have a bidirectinal relatioship mapped as</p>
  
  <pre><code>@Entity
  public class Customer {
  
    @OneToMany(mappedBy = "customer", cascade = CascadeType.ALL, orphanRemoval = true)
    private List&lt;Servers&gt; servers;
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Entity
  public class Server {
  
    @ManyToOne
    @JoinColumn(name = "...")
    private Customer customer;
  
  }
  </code></pre>
  
  <p>The problem is that I have a (Oracle) DB enforced foreign key reference in place but when I do a remove on the customer, I end up with an error saying that the @JoinColumn value in the server for the parent relation cannot be set to null. </p>
  
  <p>I have tried various optional attributes, cascade=ALL on the @ManyToOne, @PreRemove methods on the customer (trying to clear the servers list) but to no avail. Instead of first removing all servers for the client, it tried to clear the relation first, resulting in no-goodness.</p>
  
  <p>Thanks in advance,
    Nik</p>