Doctrine orm 如何在不再被引用时安全地删除实体
我有以下实体场景:Doctrine orm 如何在不再被引用时安全地删除实体,doctrine-orm,doctrine-mapping,Doctrine Orm,Doctrine Mapping,我有以下实体场景: PhyVar可以被多个PhyVarSelection引用。当我删除特定的PhyVarSelection时,如果没有其他PhyVarSelection引用该PhyVar,我想删除该PhyVarSelection oncascade={“persist”,“remove”}onPhyVarSelection将尝试删除它,即使其他选择仍在引用它oprhanremovation=true根据不是正确的答案,但我可能误解了它 手动检查是实现这一点的唯一方法吗 class PhyVarS
PhyVar
可以被多个PhyVarSelection
引用。当我删除特定的PhyVarSelection
时,如果没有其他PhyVarSelection
引用该PhyVar
,我想删除该PhyVarSelection
oncascade={“persist”,“remove”}
onPhyVarSelection
将尝试删除它,即使其他选择仍在引用它oprhanremovation=true
根据不是正确的答案,但我可能误解了它
手动检查是实现这一点的唯一方法吗
class PhyVarSelection
{
/**
* @ORM\ManyToOne(
* targetEntity="PhyVar",
* cascade={"persist"})
*
* @ORM\JoinColumn(
* name="phy_var_sel",
* referencedColumnName="id",
* nullable=false)
*/
protected $phyVar;
...
}
class PhyVar extends Variable
{
//no inverse reference
}