【问题标题】:Doctrine 2 multiple level inheritance教义 2 多级继承
【发布时间】:2023-04-08 20:14:02
【问题描述】:

我在多级继承方面遇到了一些问题

/**
 * @ORM\Entity
 * @ORM\Table(name="et_date")
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"Relative" = "DateRelative", "Absolue" = "DateAbsolue"})
 */
class Date {}

/**
 * @ORM\Entity
 * @ORM\Table(name="et_date_absolue")
 */
class DateAbsolue extends Date{}

/**
 * @ORM\Entity
 * @ORM\Table(name="et_date_relative")
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"Inscription" = "DateRelativeInscription", "Devoir" = "DateRelativeDevoir"})
 */
class DateRelative extends Date {}

/**
 * @ORM\Entity
 * @ORM\Table(name="et_date_relative_inscription")
 */
class DateRelativeInscription extends DateRelative{}

我的 DateRelative 实体的鉴别器列不存在...

【问题讨论】:

    标签: inheritance doctrine-orm


    【解决方案1】:

    这是一个老问题,但我会回答以防万一这有助于其他人......

    您不能将鉴别器列命名为“type”,因为“type”是保留的 SQL 关键字。

    我在尝试将我的一个表命名为“Like”时遇到了类似的问题,这也是一个保留的 SQL 关键字。

    作为参考,这里是所有保留 SQL 关键字列表的链接。

    http://dev.mysql.com/doc/refman/5.0/en/keywords.html

    【讨论】:

      猜你喜欢
      • 2015-06-30
      • 2015-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-25
      相关资源
      最近更新 更多