diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index 66b31678a..35b5fe0bb 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -3162,6 +3162,10 @@ class ClassMetadataInfo implements ClassMetadata */ public function mapEmbedded(array $mapping) { + if ($this->isEmbeddedClass) { + throw MappingException::noEmbeddablesInEmbeddable($this->name); + } + $this->assertFieldNotMapped($mapping['fieldName']); $this->embeddedClasses[$mapping['fieldName']] = array( diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 0b2643e2c..0ac54595d 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -781,4 +781,12 @@ class MappingException extends \Doctrine\ORM\ORMException sprintf('Missing "sequenceName" attribute for sequence id generator definition on class "%s".', $className) ); } + + public static function noEmbeddablesInEmbeddable($className) + { + return new self(sprintf( + "You embedded one or more embeddables in embeddable '%s', but this behavior is currently unsupported.", + $className + )); + } } diff --git a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php index 2baa72cd0..40768f35c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ValueObjectsTest.php @@ -162,6 +162,23 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase $reloadedCar = $this->_em->find(__NAMESPACE__.'\\DDC93Car', $car->id); $this->assertEquals($car, $reloadedCar); } + + public function testEmbeddableWithinEmbeddable() + { + $this->setExpectedException( + 'Doctrine\ORM\Mapping\MappingException', + sprintf( + "You embedded one or more embeddables in embeddable '%s', but this behavior is currently unsupported.", + __NAMESPACE__ . '\DDC93ContactInfo' + ) + ); + + $this->_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Customer'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93ContactInfo'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93PhoneNumber') + )); + } } /** @@ -263,3 +280,19 @@ class DDC93Address } } +/** @Entity */ +class DDC93Customer +{ + /** @Id @GeneratedValue @Column(type="integer") */ + private $id; + + /** @Embedded(class = "DDC93ContactInfo", columnPrefix = "contact_info_") */ + private $contactInfo; +} + +/** @Embeddable */ +class DDC93ContactInfo +{ + /** @Embedded(class = "DDC93Address") */ + private $address; +}