A lot of people use EntityGenerator (CLI) and it generate code like this. I try modify DoctrineObject to accept intance of entity or instance of collection