Doctrine 2 multiple level inheritance

2019-07-24 16:27发布

i have some trouble with multiple level inheritance

/**
 * @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{}

My discriminator column of my DateRelative entity doesn't exists...

1条回答
Animai°情兽
2楼-- · 2019-07-24 17:07

This is an old question, but I'll answer just in case this helps someone else down the road...

You cannot name your discriminator column "type", because "type" is a reserved SQL keyword.

I had a similar issue when trying to name one of my tables "Like" which is also a reserved SQL keyword.

As a reference, here is a link to a list of all reserved SQL keywords.

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

查看更多
登录 后发表回答