代码之家  ›  专栏  ›  技术社区  ›  Leandro Jacques

doctrine2中每个类的表继承未正确创建表

  •  1
  • Leandro Jacques  · 技术社区  · 6 年前

     /**
     * @ORM\Entity
     * @ORM\Table(name="persons")
     * @@ORM\InheritanceType("JOINED")
     * @ORM\DiscriminatorColumn(name="person_types", type="string")
     * @ORM\DiscriminatorMap({
     *                        "insuree" = "Insuree",
     *                        "third_party" = "ThirdParty"
     *                      })
     */
    abstract class Person {
    
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="insurees")
     */
    abstract class Insuree extends Person
    
    /**
     * @ORM\Entity
     * @ORM\Table(name="third_parties")
     */
    final class ThirdParty extends Insuree {
    

    当我执行死刑的时候架构:创建,instad of document在Person类上创建discriminator列,创建persons表,其中包含属于自己的字段,不包含其他字段;然后,使用persons表列和属于自己的列创建被保险人表,然后使用第三方表中的列创建第三方表个人和被保险人表以及属于自己的列。当我执行EntityManager::flush()时,第三方表中的所有列都被填充,其他两个表都是空的。我错过了什么?我按照官方网站上的文件,似乎我把一切都做好了。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Jannes Botis    6 年前

    这本书里有个拼写错误 @InheritanceType annotation :

    @@ORM\InheritanceType("JOINED")
    

    你有一个双“@”。

    删除其中一个“@”。