Id / primary key specified for Entity in doctrine 2
I am using Zend 2 Framework and I am trying to get data using Doctrine 2.
However, the following error appears in the Entity file.
Doctrine \ ORM \ Mapping \ MappingException
No identifier / primary key specified for Entity "Acl \ Entity \ Permission". Every object must have an id / primary key.
How can I specify the primary key?
I am using the following code.
/**
* User Permissions
*
* @ORM\Entity
* @ORM\Table(name="acl_permissions")
* @property int $id
* @property int $role_id
* @property int $resource_id
* @property string $action
*/
class Permission
{
/**
* @ORM\Column(type="integer")
*/
public $id;
/**
* @ORM\Column(type="integer")
* @ORM\OneToOne(targetEntity="Role")
* @ORM\JoinColumn(name="role_id", referencedColumnName="id")
*/
public $role;
/**
* @ORM\Column(type="integer")
* @ORM\OneToOne(targetEntity="Resource")
* @ORM\JoinColumn(name="resource_id", referencedColumnName="id")
*/
public $resource;
/**
* @ORM\Column(type="string")
*/
public $action;
public function getRole()
{
return $this->role;
}
public function getResource()
{
return $this->resource;
}
}
+3
source to share