multi_tenancy_bundle icon indicating copy to clipboard operation
multi_tenancy_bundle copied to clipboard

Identity error when working with Doctrine entities in a multitenant environment.

Open davidperezsantos opened this issue 3 months ago • 0 comments

Help @RamyHakam Problem description

When trying to persist/manage a related entity (Product) from the tenant, Doctrine throws the following error: While adding an entity of class Proxies_CG_\App\Entity\Tenant\ProductsInventory\Product with an ID hash of "1cc1bbba-7142-4e69-9985-086248e26e6f" to the identity map, another object of class App\Entity\Tenant\ProductsInventory\Product 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 hope for a response as soon as possible. Thank you for everything.

davidperezsantos avatar Sep 27 '25 02:09 davidperezsantos