[PR #11611] Issue with single table inheritance and association keys #13127

Open
opened 2026-01-22 16:16:16 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/11611

State: closed
Merged: No


Having a one to one join with a single table inheritance entity i have issues when the proxy __load results in not having an associated tuple in the joined table.
The given exception is:

Doctrine\ORM\Exception\EntityIdentityCollisionException: While adding an entity of class KanbanBOX\Core\Card\Domain\Model\CardVersion with an ID hash of "256" to the identity map,
another object of class DoctrineProxies\__CG__\KanbanBOX\Core\Card\Domain\Model\CardVersion was already present for the same ID. This exception
is a safeguard against an internal inconsistency - IDs should uniquely map to
entity object instances. This problem may occur if:

- you use application-provided IDs and reuse ID values;
- database-provided IDs are reassigned after truncating the database without
clearing the EntityManager;
- you might have been using EntityManager#getReference() to create a reference
for a nonexistent ID that was subsequently (by the RDBMS) assigned to another
entity.

Otherwise, it might be an ORM-internal inconsistency, please report it.

I'm having problems simulating my issue in Doctrine/ORM testing environment since the test is creating a FOREIGN KEY based on mapping that makes the test fail.
In our real scenario we have a database first approach so we don't really have foreign key constraints.

**Original Pull Request:** https://github.com/doctrine/orm/pull/11611 **State:** closed **Merged:** No --- Having a one to one join with a single table inheritance entity i have issues when the proxy __load results in not having an associated tuple in the joined table. The given exception is: ``` Doctrine\ORM\Exception\EntityIdentityCollisionException: While adding an entity of class KanbanBOX\Core\Card\Domain\Model\CardVersion with an ID hash of "256" to the identity map, another object of class DoctrineProxies\__CG__\KanbanBOX\Core\Card\Domain\Model\CardVersion was already present for the same ID. This exception is a safeguard against an internal inconsistency - IDs should uniquely map to entity object instances. This problem may occur if: - you use application-provided IDs and reuse ID values; - database-provided IDs are reassigned after truncating the database without clearing the EntityManager; - you might have been using EntityManager#getReference() to create a reference for a nonexistent ID that was subsequently (by the RDBMS) assigned to another entity. Otherwise, it might be an ORM-internal inconsistency, please report it. ``` I'm having problems simulating my issue in Doctrine/ORM testing environment since the test is creating a FOREIGN KEY based on mapping that makes the test fail. In our real scenario we have a database first approach so we don't really have foreign key constraints.
admin added the pull-request label 2026-01-22 16:16:16 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13127