Skip to content

ReferenceMany without targetDocument throws error in ClassMetadataFactory #258

leek opened this Issue Feb 23, 2012 · 2 comments

3 participants

leek commented Feb 23, 2012

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.

Doctrine member
jwage commented Oct 11, 2012

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 Jun 8, 2015
@malarzm malarzm modified the milestone: 1.0.0-BETA14, 1.0.0 Jun 8, 2015
@malarzm malarzm added the has PR label Jun 11, 2015
Doctrine member
malarzm commented Jun 13, 2015

#1136 was merged manually in c659449

@malarzm malarzm closed this Jun 13, 2015
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.