Error saving child entities with compound foreign keys as primary key deserialized using JMS Serializer

I have a JSON object, for example:

{
  "childEntity" : {
    "bar": "foo"
  },
  "someproperty" : "2.0"
}

I use the JMS Serializer package to deserialize this object and convert it to a Doctrine2 object:

$myObject = $serializer->deserialize($jsonStringJustAbove, "My\FooBundle\Entity\masterEntity", 'json');
$myObject = $em->merge($myObject);
$myObject->persist($tour);
$myObject->flush();

Here is my "masterEntity" class:

class masterEntity {

 /**
     * @JMS\Type("ArrayCollection<My\FooBundle\Entity\childEntity>")
     * @ORM\OneToMany(targetEntity="childEntity", mappedBy="masterEntity", cascade={"remove", "persist", "merge"})
     */
    private $childentities;

 public function setChildEntities(ArrayCollection $childentities)
 {
     $this->childentities = $childentities;
 }

}

Here is my childEntity class:

class childEntity {

 /**
     * @JMS\Type("My\FooBundle\Entity\masterEntity")
     * @ORM\ManyToOne(targetEntity="My\FooBundle\Entity\masterEntity", inversedBy="childEntities", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
     * @ORM\Id
     */
    private $masterEntity;

/**
     * @JMS\Type("My\FooBundle\Entity\barEntity")
     * @ORM\ManyToOne(targetEntity="My\FooBundle\Entity\barEntity")
     * @ORM\JoinColumn(nullable=false)
     * @ORM\Id
     */
    private $barEntity;

 public function setMasterEntity(masterEntity $masterEntity)
 {
     $this->masterEntity = $masterEntity;
 }

 public function setBarEntity(barEntity $barEntity)
 {
     $this->barEntity = $barEntity;
 }

}

The resulting my JSON object does not yet exist in the database, like all children.

I expect the deserializer to prepare masterEntity and all its children for storage in the database. My first question is: the serializer and the merge function act as follows:

$masterEntity = new masterEntity();
$childEntity = new childEntity();
$childEntity->setMasterEntity($masterEntity);
$childEntity->setBarEntity($foo);

I'm not sure, because I get this error when trying to save masterEntity (second block of code):

Notice: Undefined index: 0000000069332c43000000007c145082 in ../vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 2740

Notes: I am using Symfony 2.1.8 with Doctrine 2.3.2 and JMS Serializer dev-master (as of March 4, 2013)

, , , , ? , ? ?

.

+5

All Articles