[DDC-1397] Accesing a OneToMany relation with Child Classes and OneToOne relations. Created: 29/Sep/11 Updated: 15/Oct/11 Resolved: 15/Oct/11
|Project:||Doctrine 2 - ORM|
|Affects Version/s:||2.1, 2.1.1, 2.1.2|
|Reporter:||Gabriel Brunacci||Assignee:||Benjamin Eberlei|
Ubuntu 10.10 64bit
I am facing a small issue on Doctrine 2 that causes OneToOne relation needed to be part of the parent class. The error occurs when doing $content->getVersions() but not when doing $em->find("Model\Lantern\Content\Version", $id). The error message is:
Simply by having a look at the model we can see what's causing the Bug, will avoid class annotations to make it simpler:
As you can see, Article::$summary targets Summary::$version, but Summary::$version targets Version::$summary. This in OOP is valid as Version is contained inside Article, so doing a downcasting will get Article::summary.
The reason I believe why using $em->find works is that $em->find already knows which child class is before doing map, and relations works fine.
This bug doesn't occur with OneToMany or ManyToMany relationships.
|Comment by Gabriel Brunacci [ 29/Sep/11 ]|
A side but useful note: when I move @OneToOne relation to the parent class Version, The error doesn't happen.
|Comment by Guilherme Blanco [ 04/Oct/11 ]|
Should be the Summary::$version pointing to Article::$summary.
Your mapping is wrong conceptually in OOP, because you're referring a non-existing property of Version ($summary is only part of Article).
|Comment by Benjamin Eberlei [ 15/Oct/11 ]|
The mapping is wrong as guilherme said,