Answer the question
In order to leave comments, you need to log in
What is the correct way to specify cascade delete?
I have two entities, Roles and Rights, with a many-to-many relationship. I want that when the Rights are deleted in the JOIN table, the rules are cleared, but the associated roles are not deleted from the Roles table ... But for some reason, either:
a) When the rights are deleted, the records in the relationship table are deleted, but the associated role is also deleted.
Here is an abstract from the rights
/**
* @ORM\ManyToMany(targetEntity="Role", inversedBy="permissions", cascade={"remove"})
* @ORM\JoinTable(name="permissions_role", joinColumns={@ORM\JoinColumn(name="permissions_id", referencedColumnName="id", unique=false,onDelete="CASCADE")}, inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id", unique=false, onDelete="CASCADE")})
*/
private $roles;
/**
* @ORM\ManyToMany(targetEntity="Permissions", mappedBy="roles", cascade={"remove"})
*/
private $permissions;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question