mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Combine Single-Table-Inheritance and Embeddables (=Single-Field-Inheritance?) #5848
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MarkusRodler on GitHub (Jan 14, 2018).
Originally assigned to: @Ocramius on GitHub.
Hello,
I want to use some sort of Single-Table-Inheritance (or maybe better: Single-Field-Inheritance).
PHP Example:
I have an abstract class AbstractDifficulty.
This AbstractDifficulty has three concrete classes (HardDifficulty, MediumDifficulty and EasyDifficulty)
And I have a class called Job. Every Job has a title and one difficulty.
My database schema should therefore look like this:
In my php classes I thought it would be enough to have this:
But that is not working. Doctrine does not generate a field "difficulty" in the job table. Maybe the two features (Embeddables and SingleTable-Inheritance) are not combinable. But if they are combinable then it would be great if someone can give me a hint.
Thanks!
@Ocramius commented on GitHub (Jan 14, 2018):
That's because you either map the column as a field or as a discriminator column: doing both is not supported.
@Ocramius commented on GitHub (Jan 14, 2018):
See also https://github.com/doctrine/doctrine2/issues/5439
@Ocramius commented on GitHub (Jan 14, 2018):
Ah, by the way, embeddable entities don't support inheritance - that was never tested, so it should probably be added as a separate validation issue (metadata validation should fail)
@MarkusRodler commented on GitHub (Jan 15, 2018):
@Ocramius Thanks for the real quick reply!
But I have one question. Wouldn't it be a useful feature to combine those two features?
Without it, I have to modify my Business-Models in order to make it work with doctrine.