diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 0f0fb17aa..f358ca756 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -382,7 +382,7 @@ class ClassMetadataFactory { foreach ($parentClass->associationMappings as $field => $mapping) { if ($parentClass->isMappedSuperclass) { - if ($mapping['type'] & ClassMetadata::TO_MANY) { + if ($mapping['type'] & ClassMetadata::TO_MANY && !$mapping['isOwningSide']) { throw MappingException::illegalToManyAssocationOnMappedSuperclass($parentClass->name, $field); } $mapping['sourceEntity'] = $subClass->name; diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 14bd9ca0b..9bfe59de1 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -229,6 +229,6 @@ class MappingException extends \Doctrine\ORM\ORMException public static function illegalToManyAssocationOnMappedSuperclass($className, $field) { - return new self("It is illegal to put a one-to-many or many-to-many association on mapped superclass '".$className."#".$field."'."); + return new self("It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass '".$className."#".$field."'."); } } \ No newline at end of file diff --git a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php index 5730fcfe4..95d583f53 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -145,7 +145,7 @@ class AnnotationDriverTest extends AbstractMappingDriverTest $factory->setEntityManager($em); $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', - "It is illegal to put a one-to-many or many-to-many association on ". + "It is illegal to put an inverse side one-to-many or many-to-many association on ". "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'"); $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\UsingInvalidMappedSuperClass'); } @@ -166,7 +166,7 @@ class ColumnWithoutType class InvalidMappedSuperClass { /** - * @ManyToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser") + * @ManyToMany(targetEntity="Doctrine\Tests\Models\CMS\CmsUser", mappedBy="invalid") */ private $users; }