diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 571df0eb7..cd7a6da68 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -325,6 +325,8 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface if (!$class->discriminatorColumn) { throw MappingException::missingDiscriminatorColumn($class->name); } + } else if ($class->isMappedSuperclass && (count($class->discriminatorMap) || $class->discriminatorColumn)) { + throw MappingException::noInheritanceOnMappedSuperClass($class->name); } $this->loadedMetadata[$className] = $class; diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 11e35808c..f268d0d99 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -270,4 +270,9 @@ class MappingException extends \Doctrine\ORM\ORMException { return new self("Many-to-many or one-to-many associations are not allowed to be identifier in '$className#$field'."); } + + public static function noInheritanceOnMappedSuperClass($className) + { + return new self("Its not supported to define inheritance information on a mapped superclass '" . $className . "'."); + } } \ 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 95d583f53..031acc941 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AnnotationDriverTest.php @@ -149,6 +149,24 @@ class AnnotationDriverTest extends AbstractMappingDriverTest "mapped superclass 'Doctrine\Tests\ORM\Mapping\InvalidMappedSuperClass#users'"); $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\UsingInvalidMappedSuperClass'); } + + /** + * @group DDC-1050 + */ + public function testInvalidMappedSuperClassWithInheritanceInformation() + { + $annotationDriver = $this->_loadDriver(); + + $em = $this->_getTestEntityManager(); + $em->getConfiguration()->setMetadataDriverImpl($annotationDriver); + $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory(); + $factory->setEntityManager($em); + + $this->setExpectedException('Doctrine\ORM\Mapping\MappingException', + "Its not supported to define inheritance information on a mapped ". + "superclass 'Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'."); + $usingInvalidMsc = $factory->getMetadataFor('Doctrine\Tests\ORM\Mapping\MappedSuperClassInheritence'); + } } /** @@ -180,4 +198,14 @@ class UsingInvalidMappedSuperClass extends InvalidMappedSuperClass * @Id @Column(type="integer") @GeneratedValue */ private $id; +} + +/** + * @MappedSuperclass + * @InheritanceType("JOINED") + * @DiscriminatorMap({"test" = "ColumnWithoutType"}) + */ +class MappedSuperClassInheritence +{ + } \ No newline at end of file