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应用程序运行运行良好,我作为被抑制的错误假设。