Symfony / Doctrine:在“MappedSuperclass”中定义的Attribute添加注释 [英] Symfony / Doctrine: add annotiation to Attribute defined in 'MappedSuperclass'

查看:155
本文介绍了Symfony / Doctrine:在“MappedSuperclass”中定义的Attribute添加注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:
我学到了,我的子类有一个注释缺失(这里只是一个ID,就是GreenLeaf的thx)。
我现在的实际问题是,我不知道,如何覆盖这个,我不能让它工作。






原文:



我刚刚将Symfony 2.0应用程序迁移到Symfony 2.2,并获得无效实体信息在dev-profiler中,关于单向一对多关联。当使用

  php console doctrine:schema:validate 

我收到2条消息:

  *关联\Entity \Watched#reference表示未定义为关联的反向字段\Entity\Reference#id。 
*关联\Entity\Watched#reference表示不存在的反向字段\Entity\Reference#id。

我认为这是错误的,因为'id'是在超类中定义的。应用程序静态在旧的数据库(使用Symfony 2.0创建)上运行良好。
这是我的课程(简化):



代码:全选

 code> / ** 
* @ ORM\MappedSuperclass
* @ ORM\HasLifecycleCallbacks
* /
抽象类SuperclassAbstract {
/ **
* @ ORM\Id
* @ ORM\Column(type =integer)
* @ ORM\GeneratedValue(strategy =AUTO)
* /
protected $ id =;

//某些字段更多...
}

/ **
* @ ORM\Entity
* @ ORM\\ \\ table(name =watched)
* /
class观看扩展SuperclassAbstract {
/ **
* @ ORM\ManyToOne(targetEntity =Reference,inversedBy = id)
* @ ORM\JoinColumn(name =reference_id,referencedColumnName =id)
* /
protected $ reference;

//某些字段更多...
}

/ **
* @ ORM\Entity
* @ ORM\\ \\ table(name =reference)
* /
class引用扩展SuperclassAbstract {
//某些字段更多...
}


解决方案

我不能将教义视为关系数据库....谢谢!



我将列表添加到引用来处理关联的另一边。


Edit: I learned, that there's an annotiation missing for my subclass ('here it's just an ID', thx to GreenLeaf). My actual problem now is, that I don't know, how to override this, I can't get it to work.


Original:

I just migrated a Symfony 2.0 Application to Symfony 2.2 and get an 'invalid entities'-information in the dev-profiler, regarding an unidirectional one-to-many-association. When using the console with

php console doctrine:schema:validate

I receive 2 Messages:

* 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.

I think, that this is wrong, because 'id' is defined in a superclass. The App stills runs fine on the old DB (created with Symfony 2.0). This are my classes (simplified):

Code: Select all

/**
 * @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...
}

解决方案

I must not see doctrine as an relational DB.... thanks!

I add a list to Reference to handle the other side of the association.

这篇关于Symfony / Doctrine:在“MappedSuperclass”中定义的Attribute添加注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆