Details
Description
I have two entities :
class Structure
{
// Id and other variables
/**
* @var ArrayCollection $employees liste des employés d'une structure
*
* @ORM\OneToMany(targetEntity="Uriae\EmployeeBundle\Entity\Employee", mappedBy="structure", cascade={"all"})
*/
private $employees;
}
class Employee
{
// Id and other variables
/**
* @var integer $structure
*
* @ORM\ManyToOne(targetEntity="Uriae\StructureBundle\Entity\Structure",inversedBy="employees")
*/
private $structure;
}
The problem is when I used tests and I wan't remove a Structure the Employees aren't removed.
// Doesn't work $em->remove($structure); $em->flush(); // Bad solution but it works $em->remove($structure); $em->flush(); foreach ($employee as $employees) { $em->remove($employee); } $e->flush();
The same problem, described here
http://stackoverflow.com/questions/7766999/doctrine-2-0-vs-2-1-cascade-remove-onetomany