2014-10-18 37 views
0

當我嘗試運行php app/config doctrine:schema:update --force或只是symply在Web瀏覽器中打開我的項目,我得到這個錯誤:沒有標識符指定的錯誤Symfony2的學說ORM映射

MappingException: No identifier/primary key specified for Entity "Registration\BusinessBundle\Entity\BusinessUser". Every Entity must have an identifier/primary key. 

手動刪除應用程序/緩存文件夾,但問題依然。如果我試圖通過命令php app/console cache:clear刪除緩存,我會得到相同的錯誤。

BusinessUser實體:

<?php 
namespace Registration\BusinessBundle\Entity; 

//use FOS\UserBundle\Model\User as BaseUser; 
use Doctrine\ORM\Mapping as ORM; 

/** 
* @ORM\Entity 
* @ORM\Table(name="business_user") 
*/ 
class BusinessUser 
{ 
    /* 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

    /* 
    * @ORM\Column(type="string", length=255) 
    */ 
    protected $surname; 

    /** 
    * Get id 
    * 
    * @return integer 
    */ 
    public function getId() 
    { 
     return $this->id; 
    } 
    /** 
    * Set surname 
    * 
    * @param string $surname 
    * @return BusinessUser 
    */ 
    public function setSurname($surname) 
    { 
     $this->surname = $surname; 

     return $this; 
    } 
    /** 
    * Get surname 
    * 
    * @return string 
    */ 
    public function getSurname() 
    { 
     return $this->surname; 
    } 
} 
+0

嘗試將id列的策略從AUTO更改爲IDENTITY。 – JimL 2014-10-18 14:31:17

+0

這沒有做任何改變。 – Einius 2014-10-18 14:43:56

回答

0

你的實體不包含在使用你的學說註釋PHP的docblock意見。

Docblocks是帶有兩個星號的startet,否則它只是一個簡單的評論。

您當前的代碼

/* 
* @ORM\Id 
* @ORM\Column(type="integer") 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
protected $id; 

更改爲

/** 
* @ORM\Id 
* @ORM\Column(type="integer") 
* @ORM\GeneratedValue(strategy="AUTO") 
*/ 
protected $id; 

只有/ **將註釋被學說的認可。

請檢查您的其他屬性。