Symfony2抽象成员在第二个继承级别上重复

时间:2016-03-15 16:43:48

标签: php symfony inheritance doctrine-orm

我有以下布局: enter image description here

Taxonomy和OfferCategory是抽象的。 OfferCategory使用Doctrine注释MappedSuperClass定义一些comme成员:

/**
 * Class OfferCategory
 * @package LCH\CatalogBundle\Entity
 * @ORM\MappedSuperclass
 */
abstract class OfferCategory extends Taxonomy
{
   use Monositeable;
   /**
    * @var int the position
    * @ORM\Column(name="position", type="integer")
    */
   protected $position;

   /**
    * @var Boolean Wether OfferCategory is for mobile or not
    * @ORM\Column(name="isMobile", type="boolean")
    */
   protected $isMobile;
}

我得到了2个继承级别,当我查看生成的物理SQL时,我看到OfferCategory成员重复两次:一次在HierarchisableOfferCategory中,一次在HomeOfferCategory(和ListingOfferCateogry)中。

CREATE TABLE HierarchisableOfferCategory (id INT AUTO_INCREMENT NOT  NULL, image_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, site_id INT DEFAULT NULL, position INT NOT NULL, isMobile TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, INDEX IDX_1E8BECD13DA5256D (image_id), INDEX IDX_1E8BECD1727ACA70 (parent_id), INDEX IDX_1E8BECD1F6BD1646 (site_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE HomeOfferCategory (id INT AUTO_INCREMENT NOT NULL, position INT NOT NULL, isMobile TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;

为什么关于上述实体已经获得成员这一事实的原则呢?我该如何解决?

由于

0 个答案:

没有答案