2013-02-19 76 views
0

我创建单独generalBundle具有ModelEntity。我storeBundle延伸,使得束entity.But实体类不正确地延伸的基类中的Symfony 2.1和学说

app/console doctrine:schema:update --force 

命令不创建generalBundle fields.It只会创建storeBundle的额外创建的字段。我不确定哪里有人可以提出错误?

generalBundle模型类包含

namespace ste\GeneralBundle\Model; 

use DateTime; 

abstract class Share 
{ 
    protected $id; 
    protected $user; 
    protected $comment; 

    public function __construct() 
    { 
     $this->setCreatedAt(new \DateTime()); 
     $this->setUpdatedAt(new \DateTime()); 
    } 

    public function getId() 
    { 
     return $this->id; 
    } 



    public function setComment($comment) 
    { 
     $this->comment = $comment; 
    } 


    public function getComment() 
    { 
     return $this->comment; 
    } 
} 

generalBundle实体类包含

namespace ste\ActivityBundle\Entity; 

    use ste\GeneralBundle\Model\Share as BaseShare; 


    class Share extends BaseShare 
    { 

    } 

最后我StoreBundle实体类包含

namespace ste\StoreBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Symfony\Component\Validator\Constraints as Assert; 
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 
use Doctrine\Common\Collections\ArrayCollection; 
use ste\GeneralBundle\Entity\Share as BaseShare; 

    /** 
    * ste\StoreBundle\Entity\Share 
    * 
    * @ORM\Table(name="shares") 
    */ 
    class Share extends BaseShare 
    { 
     /** 
     * @var integer $id 
     * 
     * @ORM\Column(name="id", type="integer", nullable=false) 
     * @ORM\Id 
     * @ORM\GeneratedValue(strategy="IDENTITY") 
     */ 
     protected $id; 
    } 

这里protected $id;申请以后添加,因为我有错误像

No identifier/primary key specified for Entity "ste\StoreBundle\Entity\Share" sub class of "ste\GeneralBundle\Entity\Share". Every Enti 
    ty must have an identifier/primary key. 

而且我GeneralBundle > Resources> Config >Doctrine包含文件Share.orm.xml包含:

<?xml version="1.0" encoding="UTF-8"?> 
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping 
        http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> 

    <entity name="ste\GeneralBundle\Entity\Share" table="share"> 

     <id name="id" column="id" type="integer"> 
      <generator strategy="AUTO" /> 
     </id> 

     <field name="user" column="user_id" type="integer" /> 


     <field name="comment" column="comment" type="string" length="255" /> 


    </entity> 

</doctrine-mapping> 

没有其他的配置完成了!任何线索?有什么东西可以添加DependencyInjection

+0

'orm:info'显示缺少的类吗? – Ocramius 2013-02-19 12:52:46

+0

对不起。我不知道那个。我在哪里检查那个sholud? – stefun 2013-02-19 12:56:25

+0

这是一个CLI命令。在Symfony 2下可能是'doctrine:info' – Ocramius 2013-02-19 12:57:37

回答

0

我得到了answer.I必须在config.yml加上这些行:

orm: 
     entity_managers: 
      default: 
       mappings: 
        steStoreBundle: ~ 
        steGeneralBundle: ~ 

因为它比我的情况StoreBundle其他独立的包。