This is causing errors, when saving gridfs files with persistent metadata cache engine (like apc, memcached, etc).
I've also found same bug in Jira - http://www.doctrine-project.org/jira/browse/MODM-132 but seems that it is not fixed yet.
Added fix + tests.
Added ClassMetadata::file to list of serialized properties
Removed extra white-space