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 {
private $childentities;
public function setChildEntities(ArrayCollection $childentities)
{
$this->childentities = $childentities;
}
}
Here is my childEntity class:
class childEntity {
private $masterEntity;
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)
, , , , ?
, ? ?
.