Skip to content


Subversion checkout URL

You can clone with
Download ZIP


ReferenceMany without targetDocument throws error in ClassMetadataFactory #258

leek opened this Issue · 2 comments

3 participants


I have a @ReferenceMany defined like this:

     * @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:

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

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


We need to throw an exception here but basically this is invalid mapping. We can't have a mappedBy property if you don't tell me what class that field exists on. The targetDocument is required in this case.

@malarzm malarzm added the task label
@malarzm malarzm modified the milestone: 1.0.0-BETA14, 1.0.0
@malarzm malarzm added the has PR label

#1136 was merged manually in c659449

@malarzm malarzm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.