0

考虑班级

@Entity
public class CustomType {

  @Column
  private String name;

  @Column
  private CustomType child;

}

我有一种情况,我可以删除child实体,我希望它级联到它parent

当我尝试这样做时,我看到

Caused by: javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: DELETE on table 'CustomType' caused a violation of foreign key constraint 'FK197854DCA5BD6640' for key (bece5b16-fafd-49fd-9ff3-cc19b050e174).  The statement has been rolled back.

我错过了什么?

4

1 回答 1

2
DELETE on table 'CustomType' caused a violation of foreign key constraint

这意味着您尝试删除的行的行 ID 在另一个表中具有引用,因此无法删除。

只有当其他表中不再存在对该行的引用时,才能删除该行。

于 2013-03-14T20:47:04.770 回答