Details
Description
I got a сatchable error when merging entity that has a composite PK with association FK:
Catchable Fatal Error: Object of class TestBundle\Entity\Foo could not be converted to string in /home/context/httpd/vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php line 2606
Entities and their mapping:
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*/
class Foo
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
public $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
public $name;
/**
* @ORM\OneToMany(targetEntity="FooHasBar", mappedBy="foo", cascade={"persist", "remove", "merge"})
*/
public $children;
public function __construct()
{
$this->children = new ArrayCollection();
}
}
/**
* @ORM\Entity
*/
class Bar
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
public $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
public $name;
}
/**
* @ORM\Entity
*/
class FooHasBar
{
/**
* @ORM\Id
* @ORM\ManyToOne(targetEntity="Foo", inversedBy="children")
* @ORM\JoinColumn(name="foo_id", referencedColumnName="id", nullable=false)
*/
public $foo;
/**
* @ORM\Column(type="integer")
* @ORM\Id
*/
public $mode;
/**
* @ORM\ManyToOne(targetEntity="Bar")
* @ORM\JoinColumn(name="bar_id", referencedColumnName="id", nullable=false)
*/
public $bar;
public function __construct(Foo $foo, Bar $bar, $mode)
{
$this->foo = $foo;
$this->bar = $bar;
$this->mode = $mode;
}
}
Merged.