K
K
Kirill Nesmeyanov2016-04-19 15:01:23
symfony
Kirill Nesmeyanov, 2016-04-19 15:01:23

How to reverse `MappedSuperclass` in Doctrine?

Good day.
There is some entity:
// DocBlock omitted for cleanliness

@ORM\Entity
@ORM\Table(name="users")
class User {}

The problem is that the entity manager doesn't want to see the parent in base inheritance:
class SomeUser extends User {}

class AnyUser extends User {}

$em->persist(new SomeUser);
// => Class "SomeUser" sub class of "User" is not a valid entity or mapped super class.

Specify feedback using `@ORM\MappedSuperclass` - it's easier to shoot yourself, because the child must be "pure", it only redefines some basic characteristics (in particular, a description, an icon, etc.) and there can be a lot of similar entities (the example with users is just an example). Of course, in the base class (the user itself) there is a column by which you can determine the "user type", but this is not significant.
Those. Summing up: the problem is that I would like the mapping to "go along the inheritance chain", which does not happen. Plus, there is a little difficulty in understanding `MappedSuperclass`, because I haven't been able to run it correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Nesmeyanov, 2016-04-19
@SerafimArts

The problem is solved if the child specifies `@ORM\AttributeOverrides({})` empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question