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 に答える