1
0
mirror of synced 2025-01-19 06:51:40 +03:00

DDC-945 - Fix regression, ManyToMany unidirectional owning side assocations should be allowed.

This commit is contained in:
Benjamin Eberlei 2010-12-31 14:39:01 +01:00
parent 3498f4d6ee
commit 7112b551e2
3 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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."'.");
}
}

View File

@ -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;
}