我有两个实体 entityA.php和entityB.php
entityA.php
/**
*
* @ORM\Table(name="mytable")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({
* "foo" = "ACME\myBundle\Entity\entityB",
* })
* @ORM\Entity(repositoryClass="ACME\myBundle\Entity\entityARepository")
*/
class entityA
{
..more code
entityB.php
/**
*
* @ORM\Table(name="mytable_b")
* @ORM\Entity(repositoryClass="ACME\myBundle\Entity\entityBRepository")
*/
class entityB extends entityA
{
我想删除对象表单entityB和(不查询)也删除entityA
如果我删除表单entityA“自动”删除表单entityB但没有反之亦然
答案 0 :(得分:0)
您可以使用postRemove
实体监听器设置到您的enetityB来删除父实体。
http://docs.doctrine-project.org/en/latest/reference/events.html#entity-listeners-class