Details
Description
By using the association mapping 'One-To-Many, Self-referencing' removes the cascade.
How to follow the example below, and removed the first parent entity after the children entities.
And if you use foreign key onDelete=restrict the referential integrity error
A possible solution in the patch attached below
Category.php
<?php /** @Table(name="category") */ class Category { /** * @Id * @Column(name="id") */ public $id; /** * @OneToMany(targetEntity="Category", mappedBy="parent", cascade={"remove"}) */ public $children; /** * @ManyToOne(targetEntity="Category", inversedBy="children") * @JoinColumn(name="parent_id", referencedColumnName="id") */ public $parent; public function __construct() { $this->children = new \Doctrine\Common\Collections\ArrayCollection(); } } ?>
CREATE TABLE `category` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `parent_id` int(10) unsigned DEFAULT NULL, `name` varchar(50) NOT NULL, PRIMARY KEY (`id`), KEY `fk_id_parent_id` (`parent_id`), CONSTRAINT `fk_id_parent_id` FOREIGN KEY (`parent_id`) REFERENCES `category` (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC
Seems to be fixed already in master.
Closing the ticket.