I am trying to de-serialize json into an Entity and then Merge the Entity.
I believe I had this working in the past where I would send the ID and any fields I wished to update. For example:
In my DB:
| id | first | last | city |
| 1 | Jimmy | James | Seattle |
I would then de-serialize the following json and merge the entity
$json = { "id" : 1, "city": "chicago"}
$customer = $serializer->deserialize($json, 'App\CustomerBundle\Entity\Customer', 'json');
$em->merge($customer);
the expected result would be:
| id | first | last | city |
| 1 | Jimmy | James | Chicago |
However I am getting the following:
| id | first | last | city |
| 1 | null | null | Chicago |
Like I said I believe I had this working at some point, I am unsure if this is related to the jms_serializer
or em->merge
.
$customer->getFirst()
returns null Before and After the entity is Merged
$serializer->deserialize("{"id":1, "city": "chicago"}, .....)
would return a Entity with the properties( id => 1, first => Jimmy, last => James, city => chicago)
where city is overwritten but the rest of the data is loaded. – Shawn Northrop