0

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


原来的:

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

php console doctrine:schema:validate

我收到 2 条消息:

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

1 回答 1

0

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

我向 Reference 添加了一个列表来处理关联的另一端。

于 2013-04-16T13:37:14.527 回答