{"action":"created","issue":{"url":"https://api.github.com/repos/schmittjoh/serializer/issues/216","labels_url":"https://api.github.com/repos/schmittjoh/serializer/issues/216/labels{/name}","comments_url":"https://api.github.com/repos/schmittjoh/serializer/issues/216/comments","events_url":"https://api.github.com/repos/schmittjoh/serializer/issues/216/events","html_url":"https://github.com/schmittjoh/serializer/issues/216","id":25719007,"number":216,"title":"Warning when deserializing removed entity","user":{"login":"ddeboer","id":89267,"avatar_url":"https://avatars.githubusercontent.com/u/89267?v=3","gravatar_id":"","url":"https://api.github.com/users/ddeboer","html_url":"https://github.com/ddeboer","followers_url":"https://api.github.com/users/ddeboer/followers","following_url":"https://api.github.com/users/ddeboer/following{/other_user}","gists_url":"https://api.github.com/users/ddeboer/gists{/gist_id}","starred_url":"https://api.github.com/users/ddeboer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddeboer/subscriptions","organizations_url":"https://api.github.com/users/ddeboer/orgs","repos_url":"https://api.github.com/users/ddeboer/repos","events_url":"https://api.github.com/users/ddeboer/events{/privacy}","received_events_url":"https://api.github.com/users/ddeboer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-01-16T11:35:05Z","updated_at":"2015-05-27T13:24:25Z","closed_at":null,"body":"When a Doctrine entity is serialized, removed from the database and then  deserialized, a warning is given:\r\n\r\n```\r\nWarning: ReflectionProperty::setValue() expects parameter 1 \r\nto be object, null given in /vendor/jms/serializer/src/JMS/Serializer/GenericDeserializationVisitor.php on line 176\r\n```\r\n\r\nThe entity is then deserialized as an integer (its original id) instead of an object. The relevant code is [DoctrineObjectConstructor.php](https://github.com/schmittjoh/serializer/blob/master/src/JMS/Serializer/Construction/DoctrineObjectConstructor.php#L86): if the entity is not found, `null` is returned. \r\n\r\nSimply adding the following helps, but means that you can end up with entities that are no longer in the database:\r\n\r\n```php\r\n// Entity update, load it from database\r\n$object = $objectManager->find($metadata->name, $identifierList);\r\nif (!$object) {\r\n    return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);\r\n}\r\n```\r\n\r\nWhat would be the intended behaviour in this case?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/schmittjoh/serializer/issues/comments/105906434","html_url":"https://github.com/schmittjoh/serializer/issues/216#issuecomment-105906434","issue_url":"https://api.github.com/repos/schmittjoh/serializer/issues/216","id":105906434,"user":{"login":"brettminnie","id":6124248,"avatar_url":"https://avatars.githubusercontent.com/u/6124248?v=3","gravatar_id":"","url":"https://api.github.com/users/brettminnie","html_url":"https://github.com/brettminnie","followers_url":"https://api.github.com/users/brettminnie/followers","following_url":"https://api.github.com/users/brettminnie/following{/other_user}","gists_url":"https://api.github.com/users/brettminnie/gists{/gist_id}","starred_url":"https://api.github.com/users/brettminnie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brettminnie/subscriptions","organizations_url":"https://api.github.com/users/brettminnie/orgs","repos_url":"https://api.github.com/users/brettminnie/repos","events_url":"https://api.github.com/users/brettminnie/events{/privacy}","received_events_url":"https://api.github.com/users/brettminnie/received_events","type":"User","site_admin":false},"created_at":"2015-05-27T13:24:25Z","updated_at":"2015-05-27T13:24:25Z","body":"@magnetik have a look here #290 this is how we solved it"}}