Search code examples
doctrineunit-of-worksymfony5persist

Unable to find "Proxies\__CG__\App\Entity\EnseigneNationale" entity identifier associated with the UnitOfWork


Client.php

/**
 * @ORM\ManyToOne(targetEntity="EnseigneNationale", inversedBy="clients")
 * ...
 */
private ?EnseigneNationale $enseigneNationale;

/**
 * @ORM\OneToMany(targetEntity="ClientBanque", mappedBy="client", cascade={"persist", "remove"})
 * ...
 */
private ?Collection $clientBanques;

My data comes from an old database, I have to create a command that corrects some data in the database.

if (Condition) {
        /** @var ClientBanque $clientBanque */
        $clientBanque = $clientBanques[0];
        $clientBanque->setAA($aa);
        $this->manager->persist($client);
    }

When I persist, I got the error saying that doctrine unable to find "EnseigneNationale", that it can be nullable and I m not using it in my persist changes.

Somthing wrong with my code ?? Help Please

PHP : 7.4 Symfony : 5.3 Doctrine : 2.4


Solution

  • It was me !! Sorry for disturb, I was adding $manger->clear() who breaks everything