我是symfony2的新手,我开始了一个博客项目.该项目有两个实体,一个是posts(Noticia),另一个是comments(Comentario).我需要删除一个帖子,但我不能因为与评论的关系.
这是我的属性:
/**
* @ORM\ManyToOne(targetEntity="Noticia", inversedBy="comentarios", onDelete="SET NULL")
* @ORM\JoinColumn(name="noticia_id", referencedColumnName="id")
*/
private $noticia;
Run Code Online (Sandbox Code Playgroud)
/**
* @ORM\OneToMany(targetEntity="Comentario", mappedBy="noticia")
*/
private $comentarios = array();
Run Code Online (Sandbox Code Playgroud)
我尝试放,onDelete="SET NULL"但是当我用doctrine更新我的数据库时:php app/console doctrine:schema:update --force我收到了这个错误:
The annotation @ORM\ManyToOne declared on property Noticia
Bundle\Entity\Comentario\::$noticia does not have a property named "onDelete".
Avaible properties: targetEntity, cascade, fetch, inversedBy
Run Code Online (Sandbox Code Playgroud)