Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Validation 符号/条令:向'中定义的属性添加注释;MappedSuperclass';_Validation_Symfony_Doctrine_Mappedsuperclass - Fatal编程技术网

Validation 符号/条令:向'中定义的属性添加注释;MappedSuperclass';

Validation 符号/条令:向'中定义的属性添加注释;MappedSuperclass';,validation,symfony,doctrine,mappedsuperclass,Validation,Symfony,Doctrine,Mappedsuperclass,编辑: 我了解到,我的子类缺少一个注释('这里它只是一个ID',thx到GreenLeaf)。 我现在的实际问题是,我不知道如何克服这个,我无法让它工作 原件: 我刚刚将一个Symfony 2.0应用程序迁移到Symfony 2.2,并在dev profiler中获得了一个“无效实体”——关于单向一对多关联的信息。将控制台与一起使用时 php console doctrine:schema:validate 我收到两条信息: * The association \Entity\Watched

编辑: 我了解到,我的子类缺少一个注释('这里它只是一个ID',thx到GreenLeaf)。 我现在的实际问题是,我不知道如何克服这个,我无法让它工作


原件:

我刚刚将一个Symfony 2.0应用程序迁移到Symfony 2.2,并在dev profiler中获得了一个“无效实体”——关于单向一对多关联的信息。将控制台与一起使用时

php console doctrine:schema:validate
我收到两条信息:

* The association \Entity\Watched#reference refers to the inverse side field \Entity\Reference#id which is not defined as association.
* The association \Entity\Watched#reference refers to the inverse side field \Entity\Reference#id which does not exist.
我认为这是错误的,因为“id”是在超类中定义的。应用程序仍然可以在旧数据库(使用Symfony 2.0创建)上正常运行。 这是我的课程(简化):

代码:全选

/**
 * @ORM\MappedSuperclass
 * @ORM\HasLifecycleCallbacks
 */
abstract class SuperclassAbstract {
   /**
    * @ORM\Id
    * @ORM\Column(type="integer")
    * @ORM\GeneratedValue(strategy="AUTO")
    */
   protected $id = "";

   // some fields more...
}

/**
 * @ORM\Entity
 * @ORM\Table(name="watched")
 */
class Watched extends SuperclassAbstract {
   /**
    * @ORM\ManyToOne(targetEntity="Reference", inversedBy="id")
    * @ORM\JoinColumn(name="reference_id", referencedColumnName="id")
    */
   protected $reference;

   // some fields more...
}

/**
 * @ORM\Entity
 * @ORM\Table(name="reference")
 */
class Reference extends SuperclassAbstract {
   // some fields more...
}

我不能把教义看作是一种关系数据库。。。。谢谢


我在引用中添加了一个列表来处理关联的另一方。

在inversedBy中,应该放置一个定义为OneToMany的字段。在这里,它只是一个id,这就是为什么它是错误的。