mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1635: Single Table Inheritance and a composite key gives the wrong entity when using the IdentityMap #2052
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 @doctrinebot on GitHub (Feb 6, 2012).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user h-andreas:
Given the following data, a single table inheritance with 'type' being the discriminator column and a composite key of (type, key, foreign):
||type||key||foreign||
|type-1|key-1|xyz|
|type-2|key-1|xyz|
As Doctrine only takes the columns 'key' and 'foreign' into the composite key, it gives me an instance of the class being mapped to 'type-1' when wanting to select an instance of 'type-2' with key=key-1 && foreign=xyz. BUT this only occurs when i already fetched the instance mapped to type-1 with the same values.
@doctrinebot commented on GitHub (Feb 10, 2012):
Comment created by @beberlei:
The type can never be part of the primary key, how did you even map that? can you post details?
@doctrinebot commented on GitHub (Feb 14, 2012):
Comment created by h-andreas:
I did not specified type as being part of the primary key ... for obvious reasons. I didnt even thought of it being necessary as this is the only time we are using single table inheritance.
This is an abstracted version of our domain model:
When calling
$em->find('Task', 1)->getAttributes()and then doing$em->find('User', 1)->getAttributes()it gives me an instance of TaskAttribute for the user instead of a fresh UserAttribute.@doctrinebot commented on GitHub (Feb 18, 2012):
Comment created by @beberlei:
To have type part of the primary key you have to map it as field. Discrimnator columns can never be part of the PK for doctrine, even if they are in the database.
You can change your domain model to something like
@doctrinebot commented on GitHub (Feb 18, 2012):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Feb 20, 2012):
Comment created by h-andreas:
But then i cant use table inheritance.
@doctrinebot commented on GitHub (Feb 20, 2012):
Comment created by @beberlei:
Yes, you can't in your scenario, its just not supported with the discriminator column in it.