Hibernate throws Cannot delete or update a parent row: a foreign key constraint fails

前端 未结 2 554
臣服心动
臣服心动 2020-12-10 06:36

I am working on a basic example to test cascade delete operation but I am getting exception.

I have below entities:

Employee.java

2条回答
  •  [愿得一人]
    2020-12-10 07:19

    The REMOVE cascade type is for the standard JPA remove() operation. For the native Hibernate delete() operation, you need to use a Hibernate-proprietary annotation:

    @Cascade(CascadeType.DELETE)
    

提交回复
热议问题