我有班级建设:
@JsonBackReference
@OneToMany(cascade = CascadeType.MERGE, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "building")
private List<Floor> floorList = new ArrayList<>();
另一方面:
@JsonManagedReference
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "BUILDING_ID")
private Building building;
现在我根本无法删除建筑,当我尝试删除byid(id)时,出现了以下错误:
org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Naruszenie więzów integralności: "FKNRVYGRFI0C51V0GF7JI9KF4QK: PUBLIC.ASSET FOREIGN KEY(FLOOR_ID) REFERENCES PUBLIC.FLOOR(ID) (129)"
Referential integrity constraint violation: "FKNRVYGRFI0C51V0GF7JI9KF4QK: PUBLIC.ASSET FOREIGN KEY(FLOOR_ID) REFERENCES PUBLIC.FLOOR(ID) (129)"; SQL statement:
delete from floor where id=? [23503-200]
我尝试过cascade=cascadetype.all、merge、remove和without cascade,但都没有效果。删除建筑的唯一方法是首先删除所有楼层(floorlist为空)。
暂无答案!
目前还没有任何答案,快来回答吧!