I have created the following abstract class, which use single table inheritance and maps subclasses on the DiscriminatorColumn model
.
/**
* @Entity
* @Table(name="entity")
* @InheritanceType("SINGLE_TABLE")
* @DiscriminatorColumn(name="model", type="string")
* @DiscriminatorMap({
* "green" = "model\GreenEntity",
* "blue" = "model\BlueEntity"
* })
*/
abstract class AbstractEntity
{
/** @Id @Column(type="string") */
protected $entity_id;
}
Let's say I extend the abstract class AbstractEntity
by some classes:
class GreenEntity extends AbstractEntity {}
class BlueEntity extends AbstractEntity {}
And extend these by some more subclasses
class GreenEntityChildOne extends GreenEntity {}
class GreenEntityChildTwo extends GreenEntity {}
class BlueEntityChildOne extends BlueEntity {}
class BlueEntityChildTwo extends BlueEntity {}
Now, for example, when I instantiate GreenEntityChildOne
and persist it to the database, it will throw an exception that I don't have a mapping for it.
What I'm trying to do is get GreenEntityChildOne
to be mapped as GreenEntity
(or rather, every class which extends a class below AbstractEntity
to be mapped as the class which extends the upper abstract class).
Is this at all possible?