In the project, I use doctrine 2, where I have from one to many relationships:
Customer => Orders
My problem is similar to this question, except that I am already getting an error when trying to get an object using arraycollection ():
Warning: spl_object_hash() expects parameter 1 to be object, null given in C:\xampp\htdocs\test.example.com\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php on line 2852
The content of Customer.php looks something like this:
<?php namespace Application\Entity; use Doctrine\ORM\Mapping as ORM; class Customer { public function __construct() { $this->orders = new \Doctrine\Common\Collections\ArrayCollection(); } private $id; private $orders; public function getOrders() { return $this->orders; } public function setId(\Application\Entity\User $id) { $this->id = $id; return $this; } public function getId() { return $this->id; } }
Update: And here is the code causing the error:
$entityManager->getRepository('\Application\Entity\Customer')->find($user->getId());
Update2: Since the identifier inside the client is a User object, I also tried to follow without success:
$entityManager->getRepository('\Application\Entity\Customer')->find($user);
I already tried to answer this page , but it didn’t help! What do I need to do to make this work?
source share