doctrine2中按类继承的表无法正确创建表

时间:2018-08-31 21:28:30

标签: php doctrine-orm laravel-5.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 {

当我执行schema:create,instad时,在Person类上创建了discriminator列,它创建了具有所属字段的persons表,仅此而已,然后,创建了具有persons表列和insures表的insurees表。属于自己的列,然后使用person和insures表中的列以及属于自己的列创建了third_parties表。当我执行EntityManager :: flush()时,third_parties表中的所有列均已填充,而其他两个表均为空。我想念什么?我遵循了教义官方网站上的文档,似乎我做对了所有事情。

1 个答案:

答案 0 :(得分:1)

@InheritanceType annotation中有一个错字:

@@ORM\InheritanceType("JOINED")

您有一个双“ @”。

这将导致注释被忽略。

删除“ @”之一。