I went through a strange "bug".
I have 2 associations on an entity with "almost the same same" :
/**
* @ORM\OneToOne(targetEntity="TaxeApprentissage\Entity\Collecteur\Parametres", mappedBy="collecteur")
*/
private $parametres;
/**
* @ORM\OneToOne(targetEntity="TaxeApprentissage\Entity\Collecteur\ParametresEdition", mappedBy="collecteur")
*/
private $parametresEdition;
When lazy loading happens, I got the exact same object TaxeApprentissage\Entity\Collecteur\ParametresEdition
in both properties $parametres
and $parametresEdition
.
But when I reverse the associations :
/**
* @ORM\OneToOne(targetEntity="TaxeApprentissage\Entity\Collecteur\ParametresEdition", mappedBy="collecteur")
*/
private $parametresEdition;
/**
* @ORM\OneToOne(targetEntity="TaxeApprentissage\Entity\Collecteur\Parametres", mappedBy="collecteur")
*/
private $parametres;
Everything is working perfectly. I get the correct object for each association.
Is it caused by the fact that the entities are named almost similar?
It is probably because you made a mistake on the owning side? What do the column definitions on other side (inside Parametres
and ParametresEdition
) look like? You don't show them in your question.
You probably have twice inversedBy="parametres"
or inversedBy="parametresEdition"
.
@ORM\OneToOne(targetEntity="TaxeApprentissage\Entity\Collecteur\Collecteur", inversedBy="????")
@ORM\OneToOne(targetEntity="TaxeApprentissage\Entity\Collecteur\Collecteur", inversedBy="????")