php - JMSSerializerBundle, Deserialize doesn't Relationship After Persist -
deserialization process onetomany-manytoone process relation data sets null.
the result entity:
@orm\onetomany(targetentity="\acme\demobundle\entity\answercontent", mappedby="answerresult", cascade={"persist", "remove"}, orphanremoval=true) @jms\type("arraycollection<acme\demobundle\entity\answercontent>") @jms\groups({"survey_answer_fetching"})
the answer entity:
@orm\manytoone(targetentity="acme\demobundle\entity\answerresult", inversedby="answers") @orm\joincolumn(name="answer_result_id", referencedcolumnname="id") @jms\type("acme\demobundle\entity\answerresult")
here json:
{"results": [{"answers":[ {"choices":[{"fieldid":1}],"value":"","questionid":45}, {"choices":[{"fieldid":1}],"value":"","questionid":67}], "someid":9 }], "personid":18} $serializer = $this->get('jms_serializer'); $data = $serializer->deserialize($json['json'], 'acme\\demobundle\\entity\\answerresult', 'json');
and deserialize process assings values...
everything fine, json variables sets correct entity properties.
$em->persist($data); $em->flush();
the values passes db relations not... documentations of jmsserializationbundle. jms types defined...
but db/doctrine doesn't map relations...
i solved same problem merge() function :
$entity = $em->merge($data); $em->persist($entity); $em->flush();
Comments
Post a Comment