SF2和Doctrine有一個奇怪的問題。當試圖從app.php運行我的應用程序我得到這個:Symfony2 Docrtine - 每個實體都必須有一個標識符/主鍵 - 它有一個主鍵?
[2013-01-31 15:40:05] request.CRITICAL: Doctrine\ORM\Mapping\MappingException: No identifier/primary key specified for Entity 'ACME\MyBundle\Entity\MyEntity'. Every Entity must have an identifier/primary key. (uncaught exception) at /lib/Doctrine/ORM/Mapping/MappingException.php line 37 [] []
這似乎相當自我解釋。但據我所看到的,我有我的實體主鍵:
我的實體:
/**
* @ORM\Entity
* @ORM\Table(name="milestone")
*/
class MyEntity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string")
* @Assert\NotBlank()
* @Assert\MinLength(2)
* @Assert\MaxLength(100)
*/
protected $title;
/**
* @ORM\Column(type="datetime")
* @Assert\NotBlank()
*/
protected $date;
//////ETC
然後在phpMyAdmin:
Action Keyname Type Unique Packed Column Cardinality Collation Null Comment
Edit Drop PRIMARY BTREE Yes No id 63 A
我的主鍵。非空。
使用app_dev.php應用程序運行運行良好,我作爲被抑制的錯誤假設。