我班上有两个关系:
@OneToOne(mappedBy = "poi", cascade = { CascadeType.ALL })
@CascadeOnDelete
protected PoiDescription description;
@OneToMany(mappedBy = "poi", cascade = { CascadeType.ALL })
@CascadeOnDelete
protected List<PoiAdditional> additionals = new ArrayList<>();
在我生成的 DDL(用于 postgres)中,我变成:
ALTER TABLE POI_DESCRIPTION ADD CONSTRAINT FK_POI_DESCRIPTION_POI_ID FOREIGN KEY (POI_ID) REFERENCES POI (ID)
ALTER TABLE POI_ADDITIONAL ADD CONSTRAINT FK_POI_ADDITIONAL_POI_ID FOREIGN KEY (POI_ID) REFERENCES POI (ID) ON DELETE CASCADE
为什么关系@OneToMany 有语句“ON DELETE CASCADE”而关系@OneToOne 没有?
提前致谢