doctrine/mongodb-odm — Issue #258: ReferenceMany without targetDocument throws error in ClassMetadataFactory
Author: leek
Created: 2012-02-23 05:12:40+00:00
State: open

I have a `@ReferenceMany` defined like this:

```php
/**
* @MongoDB\ReferenceMany(mappedBy="post")
*/
protected $activity;
```

This works great until I try to serialize the object (using `JMSSerializerBundle`) as the MongoDB ODM throws the following error:

> Warning: class_parents() [function.class-parents]: object or string expected in ...\\doctrine-mongodb-odm\\lib\\Doctrine\\ODM\\MongoDB\\Mapping\\ClassMetadataFactory.php line 336

Following the stack trace leads me to line 693 of DocumentPersister.php:

```php
$targetClass = $this->dm->getClassMetadata($mapping['targetDocument']);
```

`$mapping['targetDocument']` in this instance is `null`.