Doctrine Cascade Operations
Cascading operations mean that when you perform a persist , remove , merge (deleted), detach , refresh (does not work) operation on an entity, the same operation will also be performed on the associated entity. Persist The persist operation saves the new entity to the database. The persist operation only needs to be performed when a new entity needs to be created, if the entity was obtained from the repository, then persist is not necessary, since the changes are already tracked by the EntityManager, it is enough to just flush . When specifying cascade: ['persist'] , persist will also be executed on the related entity. When cascade: ['persist'] is NOT specified #[ORM\Entity(repositoryClass: ProductRepository::class)] class Product { #[ORM\OneToOne(mappedBy: 'product')] private ?Photo $photo = null; } #[ORM\Entity(repositoryClass: PhotoRepository::class)] class Photo { #[ORM\OneToOne(inversedBy: 'photo')] #[ORM\JoinColumn(nul...