Answer the question
In order to leave comments, you need to log in
Why is the entity that has a one-to-one relationship to itself not deleted?
Tell me why the entity in which the one-to-one relationship to itself is not deleted?
There are 2 related entities:
Course < Section
The section has this relationship in the entity:
Section.php
/**
* @ORM\OneToOne(targetEntity=Section::class, cascade={"persist", "remove"})
*/
private $after_send_section;
An exception occurred while executing 'DELETE FROM section WHERE id = ?' with params [5]:
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`database`.`section`, CONSTRAINT `FK_2D737AEF628DC59B` FOREIGN KEY (`after_send_section_id`) REFERENCES `section` (`id`))
Answer the question
In order to leave comments, you need to log in
/**
* @ORM\OneToOne(targetEntity=Section::class)
* @ORM\JoinColumn(name="after_send_section", referencedColumnName="id", onDelete="CASCADE")
*/
private $after_send_section;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question