mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
InheritanceType SINGLE_TABLE is not changing target Entity when Dicscriminator changes but not Id #6616
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 @EtienneLancon on GitHub (Jan 28, 2021).
Hi,
I'm quite new to both Doctrine and Symfony so there probably is something i missed.
I'm trying to make a single table inheritance from an abstract class to many children entities. It works pretty well.
But when i request an entity embedding many of these children entities. If both of them have the same Id, it seems Doctrine makes the assumption that this is the same object even if they should not have the same discriminator. For information this is a legacy database and there is no true unique Id.
When i subscribe postLoad event, once embedding entity is loaded, embedded properties that will fail are yet of the wrong proxy type.
Maybe there is a way to disable this assumption process made by Doctrine ?
Or maybe I'm totally wrong, as i said i'm quite new.
Thanks in advance for any help.
Here is the mother class.
A child class.
And an entity snippet in which it is related.
@beberlei commented on GitHub (Feb 7, 2021):
Doctrine single table inheritence requires the ID to be unique across all types of hierarchy. You could make it a composite key over the id and discriminator value.