1

I have the following Entity scenario:enter image description here

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

}

PhyVar could be referenced by multiple PhyVarSelection. When I delete a specific PhyVarSelection, I would like to delete the PhyVar if no other PhyVarSelection is referencing that PhyVar anymore.

oncascade={"persist", "remove"} on PhyVarSelection would try to remove it even though other selections are still referencing it. oprhanRemoval=true according to this well written explanation is not the right answer, but I could have misunderstood it.

Is a manual check the only way to accomplish this?

GavinoGrifoni
  • 743
  • 2
  • 12
  • 33
Bertuz
  • 2,390
  • 3
  • 25
  • 50

0 Answers0