mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Duplicate definition of column … on inherited embeddable #5916
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 @havvg on GitHub (Mar 9, 2018).
Hi there, I got two value objects,
TimeframeandBoundedTimeframe, which extendsTimeframe.When I try to setup the mapping file for
BoundedTimeframeI get the following exception (ORM v2.5.12). I tried removing the duplicate definitions from the mapping file, no success. How is it possible to use embeddable which are part of inheritance?@Ocramius commented on GitHub (Mar 9, 2018):
Please do check ORM 2.6.x first.
@havvg commented on GitHub (Mar 9, 2018):
The issue exists on 2.6, too.
@Ocramius commented on GitHub (Mar 9, 2018):
Thanks for checking 👍
On 9 Mar 2018 19:05, "Toni Uebernickel" notifications@github.com wrote:
@fabschurt commented on GitHub (Nov 12, 2018):
@havvg I had the EXACT same problem. I know I’m a bit late, but here is how I solved it:
First, you’ll want to use
attributeOverrideinstead offieldsin the mapping of the inheriting class:Note that you would still have to do that even if the field definitions were exactly the same (here, the
nullableattribute has a different value), otherwise you would have problems with the DQL query builder that would use an unmapped base alias for these fields when you wouldselectall fields via$repository->createQueryBuilder('some_alias')for example.Second, you’ll want to set the visibility of the inherited properties to
protectedinstead ofprivatein the base class:I know this is not ideal, but we’re dealing with inheritance here, so nothing will ever be ideal anyway…
It should work 🙂
@Ocramius, do you think this is worth a PR adding some documentation about this particular edge case?
@Ocramius commented on GitHub (Nov 12, 2018):
@havvg seems like hacks all the way down there. Would probably be better to have embeddable replace metadata for fields, instead of inheriting parent fields and having the re-declaration rules of entities.
@fabschurt commented on GitHub (Nov 12, 2018):
@Ocramius Mmh yeah I guess. I can try to make a PR for this 🙂