doctrine/orientdb-odm — pull request #187 by mitom (2014-12-16 14:10:07+00:00)
Title: Fix mapping and hydration

So this is actually a fairly critical fix. Originally the mapping of ODB -> PHP was done via pubic vars and public setters. I have already took a look at this in #186 but didn't realise that this was actually a more serious issue, due to the fact that the ProxyFactory from doctrine common uses reflection to set the RID on proxies, so in case they were protected, an error was thrown. Therefore I took my fix from there and extracted it so it can be merged earlier.

The 2nd thing is, when proxies were filled from collections, or queries they weren't marked as initialized so when touched they were hydrating again, querying the same data twice.

The last thing, which is not a bug but a note for writing tests: If mock result data is used (which I assume contains invalid RIDs), the rid property of the PHP object must be **protected**, public would result in the proxy trying to hydrate itself when the RID is set (since there is no public setter), which effectively means it will throw an error since the rid is invalid and can't be loaded. Actually I would encourage adding this as a note for all the mappings, RIDs are never meant to be set or changed, only fetched so mapping them as protected would make the most sense.

cc @weinr0ck