0

When I create a class child# that I fill its values and that I save it in DB (persistent, flush) I have no worries, all is database.

When I pick a Child# up from the database. All the attributes of the Parent1 are not hydrated, I do have those of the GrandParent, the Child# but not those of the Parent1, why?

/**
 * @ORM\Entity
 * @ORM\InheritanceType("JOINED")
 * @ORM\DiscriminatorColumn(name="class", type="int")
 * @ORM\DiscriminatorMap({
 *    0 = "Parent2",
 *    1 = "Child1", 
 *    2 = "Child2"})
 */
abstract class GrandParent { ... }

/** @ORM\Entity */
abstract class Parent1 extends GrandParent { ... }

/** @ORM\Entity */
class Parent2 extends GrandPArent { ... }

/** @ORM\Entity */
class Child1 extends Parent1 { ... }

/** @ORM\Entity */
class Child2 extends Parent1 { ... }

thanks for your help.

  • I'm thinking this line is your issue: ` @ORM\DiscriminatorColumn(name="class", type="int")`. By default and all throughout Doctrine they use a "string" type for the discriminator. Could you give that a shot? Also, there's no need to declare a DiscrimatorMap (just leave it out completely), Doctrine will handle creating one if you don't provide one, more info in [an old answer of mine](https://stackoverflow.com/a/45015357/1155833) – rkeet Apr 15 '18 at 14:50
  • I love you ! Thanks ! really thanks ! – Kantin Charignon Apr 16 '18 at 08:08

0 Answers0