1
0
mirror of synced 2025-01-23 16:51:41 +03:00

[DDC-3027] Avoid duplicated mapping using Embedded in MappedSuperclass

This commit is contained in:
Eduardo García Sanz 2014-04-30 11:46:54 +02:00
parent 7a305475e3
commit 8a3def097f
2 changed files with 40 additions and 6 deletions

View File

@ -141,7 +141,10 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
$this->completeIdGeneratorMapping($class); $this->completeIdGeneratorMapping($class);
} }
if (!$class->isMappedSuperclass) {
foreach ($class->embeddedClasses as $property => $embeddableClass) { foreach ($class->embeddedClasses as $property => $embeddableClass) {
if (isset($embeddableClass['inherited'])) { if (isset($embeddableClass['inherited'])) {
continue; continue;
} }
@ -149,6 +152,7 @@ class ClassMetadataFactory extends AbstractClassMetadataFactory
$embeddableMetadata = $this->getMetadataFor($embeddableClass['class']); $embeddableMetadata = $this->getMetadataFor($embeddableClass['class']);
$class->inlineEmbeddable($property, $embeddableMetadata); $class->inlineEmbeddable($property, $embeddableMetadata);
} }
}
if ($parent && $parent->isInheritanceTypeSingleTable()) { if ($parent && $parent->isInheritanceTypeSingleTable()) {
$class->setPrimaryTable($parent->table); $class->setPrimaryTable($parent->table);

View File

@ -17,6 +17,8 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Address'), $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Address'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Vehicle'), $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Vehicle'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Car'), $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC93Car'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3027Animal'),
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3027Dog'),
)); ));
} catch(\Exception $e) { } catch(\Exception $e) {
} }
@ -212,6 +214,15 @@ class ValueObjectsTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this->assertEquals($expectedColumnName, $actualColumnName); $this->assertEquals($expectedColumnName, $actualColumnName);
} }
public function testInlineEmbeddableInMappedSuperClass()
{
$isFieldMapped = $this->_em
->getClassMetadata(__NAMESPACE__ . '\DDC3027Dog')
->hasField('address.street');
$this->assertTrue($isFieldMapped);
}
} }
@ -396,3 +407,22 @@ class DDC3028Id
$this->id = $id; $this->id = $id;
} }
} }
/**
* @MappedSuperclass
*/
abstract class DDC3027Animal
{
/** @Id @GeneratedValue(strategy = "AUTO") @Column(type = "integer") */
public $id;
/** @Embedded(class = "DDC93Address") */
public $address;
}
/**
* @Entity
*/
class DDC3027Dog extends DDC3027Animal
{
}