原则 2 中每个类的表继承未正确创建表



我有一个这样的类继承

/**
* @ORMEntity
* @ORMTable(name="persons")
* @@ORMInheritanceType("JOINED")
* @ORMDiscriminatorColumn(name="person_types", type="string")
* @ORMDiscriminatorMap({
*                        "insuree" = "Insuree",
*                        "third_party" = "ThirdParty"
*                      })
*/
abstract class Person {

/**
* @ORMEntity
* @ORMTable(name="insurees")
*/
abstract class Insuree extends Person
/**
* @ORMEntity
* @ORMTable(name="third_parties")
*/
final class ThirdParty extends Insuree {

当我执行 schema:create 时,原则的 instad 在 Person 类上创建了鉴别器列,它创建了包含属于自己的字段的 persons表,仅此而已,然后,创建了包含人员表列和属于自身的列的被保险人表,然后创建了包含来自人员和被保险人表的列以及属于自己的列的third_parties表。当我执行 EntityManager::flush(( 时,third_parties表中的所有列都被填充了,其他两个表都是空的。我错过了什么?我关注了教义官方网站上的文档,似乎我做的一切都正确了。

@InheritanceType注释中有一个拼写错误:

@@ORMInheritanceType("JOINED")

你有一个双"@"。

这会导致注释被忽略。

删除其中一个"@"。

最新更新