Doctrine2主键

时间:2013-07-29 16:24:24

标签: mysql doctrine-orm annotations

这是我的Doctrine2 Annotation文件,它返回给我这个错误

  

MappingException:没有为Entity指定标识符/主键   “WbsGo \ clientsBundle \实体\ VtigerPortalinfo”。每个实体都必须拥有   标识符/主键。

在DB中,字段ID设置为主键...所以我不知道问题出在哪里....

<?php

namespace WbsGo\clientsBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * VtigerPortalinfo
 */
class VtigerPortalinfo
{
    /**
     * @var string
     */
    private $userName;

    /**
     * @var string
     */
    private $userPassword;

    /**
     * @var string
     */
    private $type;

    /**
     * @var \DateTime
     */
    private $lastLoginTime;

    /**
     * @var \DateTime
     */
    private $loginTime;

    /**
     * @var \DateTime
     */
    private $logoutTime;

    /**
     * @var integer
     */
    private $isactive;

    /**
     * @var \WbsGo\clientsBundle\Entity\VtigerContactdetails
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;


    /**
     * Set userName
     *
     * @param string $userName
     * @return VtigerPortalinfo
     */
    public function setUserName($userName)
    {
        $this->userName = $userName;

        return $this;
    }

    /**
     * Get userName
     *
     * @return string 
     */
    public function getUserName()
    {
        return $this->userName;
    }

    /**
     * Set userPassword
     *
     * @param string $userPassword
     * @return VtigerPortalinfo
     */
    public function setUserPassword($userPassword)
    {
        $this->userPassword = $userPassword;

        return $this;
    }

    /**
     * Get userPassword
     *
     * @return string 
     */
    public function getUserPassword()
    {
        return $this->userPassword;
    }

    /**
     * Set type
     *
     * @param string $type
     * @return VtigerPortalinfo
     */
    public function setType($type)
    {
        $this->type = $type;

        return $this;
    }

    /**
     * Get type
     *
     * @return string 
     */
    public function getType()
    {
        return $this->type;
    }

    /**
     * Set lastLoginTime
     *
     * @param \DateTime $lastLoginTime
     * @return VtigerPortalinfo
     */
    public function setLastLoginTime($lastLoginTime)
    {
        $this->lastLoginTime = $lastLoginTime;

        return $this;
    }

    /**
     * Get lastLoginTime
     *
     * @return \DateTime 
     */
    public function getLastLoginTime()
    {
        return $this->lastLoginTime;
    }

    /**
     * Set loginTime
     *
     * @param \DateTime $loginTime
     * @return VtigerPortalinfo
     */
    public function setLoginTime($loginTime)
    {
        $this->loginTime = $loginTime;

        return $this;
    }

    /**
     * Get loginTime
     *
     * @return \DateTime 
     */
    public function getLoginTime()
    {
        return $this->loginTime;
    }

    /**
     * Set logoutTime
     *
     * @param \DateTime $logoutTime
     * @return VtigerPortalinfo
     */
    public function setLogoutTime($logoutTime)
    {
        $this->logoutTime = $logoutTime;

        return $this;
    }

    /**
     * Get logoutTime
     *
     * @return \DateTime 
     */
    public function getLogoutTime()
    {
        return $this->logoutTime;
    }

    /**
     * Set isactive
     *
     * @param integer $isactive
     * @return VtigerPortalinfo
     */
    public function setIsactive($isactive)
    {
        $this->isactive = $isactive;

        return $this;
    }

    /**
     * Get isactive
     *
     * @return integer 
     */
    public function getIsactive()
    {
        return $this->isactive;
    }

    /**
     * Set id
     *
     * @param \WbsGo\clientsBundle\Entity\VtigerContactdetails $id
     * @return VtigerPortalinfo
     */
    public function setId(\WbsGo\clientsBundle\Entity\VtigerContactdetails $id = null)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Get id
     *
     * @return \WbsGo\clientsBundle\Entity\VtigerContactdetails 
     */
    public function getId()
    {
        return $this->id;
    }
}

1 个答案:

答案 0 :(得分:1)

也许如果您更改此行的$ id的注释行:

*ORM\GeneratedValue(strategy="IDENTITY")