For the following schema:
Animal - age - gender - size
Cat extends Animal - fur_color
Snake extends Animal - scales_color
Elephant extends Animal - tusks_size
When I do $em->getRepository('AcmeDemoBundle:Animal')->findAll()
I will recieve a collection on Animal
objects without their subclass properties.
When I do $em->getRepository('AcmeDemoBundle:Cat')->findAll()
I will recieve the objects with their subclass (Cat) properties, however I will get only Cat objects (no snakes or elephants).
Eg. for database like this:
Animals table:
ID | discr | age | gender | size | fur_color | scales_color | tusks_size
1 | snake | 2 | male | 20ft | NULL | green | NULL
2 | cat | 3 | female | 5ft | red | NULL | NULL
3 | eleph | 6 | male | 99ft | NULL | NULL | 40ft.
4 | cat | 2 | male | 6ft | grey | NULL | NULL
I'd like to recieve a Collection of:
Indeed it seems I had some error in my configuration. Recreating the bundle and writing the entities again fixed the problem as @Bez and @Cerad suggested.