title: Integrity Constraints violation error when deleting record in Spring boot
body: <p>I am new into Spring Boot framework, I want to implement an Entity Relationships so to achieve the following cases:</p>
  <p>Consider the following example Entities Relationships</p>
  <pre class="lang-java prettyprint-override"><code>@Entity
  class Category {
    private Long id;
    private String name
  
    @OneToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
    private List&lt;Product&gt; products = new ArrayList&lt;&gt;();
  }
  
  
  @Entity
  class Product {
    private Long id;
    private String name
    
    @ManyToOne(fetch=FetchType.EAGER, cascade=CascadeType.DETACH)
    private Category category;
  }
  </code></pre>
  <p>I use the below approach to delete objects with Jpa Repository API</p>
  <pre class="lang-java prettyprint-override"><code>Product product = productRepository.getOne(productId);
  productRepository.delete(product);
  
  Category category = categoryRepository.getOne(categoryId);
  categoryRepository.delete(category);
  
  </code></pre>
  <p>Based on the above relationships I want to be able to:</p>
  <ol>
  <li>When deleting Category record, delete all related Products.</li>
  <li>When deleting Product record, detach from the Category's products</li>
  </ol>
  <p>I am aware of the cascade types but when deleting Category record I get constraints violation i.e. category x is still referenced into another table i.e. Products.</p>