我有一个名为Step2的实体(有多个 selectedriskassesments 实体,这是一个带有额外字段的 RiskAssestment 实体):
......................
manyToMany:
selectedriskassesments:
targetEntity: **SelectedRiskAssesment**
joinTable:
name: step2_selected_risk_assesments
joinColumns:
step2_id:
referencedColumnName: id
inverseJoinColumns:
selected_risk_id:
referencedColumnName: id
cascade: ["persist","remove"]
..............................
SelectedRiskAssesment实体具有:
manyToOne:
risk_assesment:
targetEntity: RiskAssestment
inversedBy: selectedriskassesment
joinColumn:
name: risk_assesment
referencedColumnName: id
orphanRemoval: true
这是调查的一部分,我想删除 Step2实体及其选定的风险评估,但我得到:
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`phsafety`.`step2_selected_risk_assesments`, CONSTRAINT `FK_FAFC9298EA71C84F` FOREIGN KEY (`selected_risk_id`) REFERENCES `selectedriskassesment` (`id`))
我曾尝试使用orphanRemoval: true解除与RiskAssestment实体的绑定...任何帮助都会很棒