I define two entities with bidirectional relations:
One
AppEntityProduct: ... manyToOne: productSet: targetEntity: AppEntityProductSet inversedBy: products cascade: ["all"] joinColumn: onDelete: RESTRICT ...
And two
AppEntityProductSet: ... oneToMany: products: targetEntity: AppEntityProduct mappedBy: productSet cascade: ['all'] ...
If I drop all related Product
entities, the related productSet
entity automatically dropped too. And I don’t understand why. How I prevent this behavior?
Doctrine version 2.6.3
Advertisement
Answer
according to docs – https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/working-with-associations.html#transitive-persistence-cascade-operations
and you have cascade: ['all']
– the behavior is as expected