Nested objects are not persisted
marcinmateuszwisniewski opened this issue · 2 comments
Hello.
I have a problem with saving an POPO in database for my Symfony 3.3 project.
I create a new entity (Character), which helds a CharacterSkills POPO, which contains two arrays.= for other POPO, Skill.
`
(in Character.php)
{
/**
* @ORM\Column(type="json_document",nullable=true, options={"jsonb": true})
*/
public $skillList;
`
namespace AppBundle\Utilities;
use AppBundle\Utilities\Skills\Skill;
class CharacterSkills
{
private $commonSkills = array();
private $battleSkills = array();
}
The problem is, that something wrong happens during serialization, I use MariaDB (from XAMPP, MySQL 5.7+), and after putting the POPO in Entity and persisting, Doctrine calculates ChangeSet properly (proved by dumping in my custom event listener), but in database goes only info 'bout type of CharacterSkills:
{"#type":"AppBundle\Utilities\CharacterSkills"}
What wrong is happening? Doctrine and DBAL are updated. Further var_dumping shows, that data is lost in Symfony\Component\Serializer\Serializer.php
normalization , but why this can happen?
Nevermind, forgotten to add setters/getters in the nested classes. Shame on me.
I simply panicked, while I have my diploma thesis deadline soon