“没有为实体指定的标识符/主键” - 扩展FOS用户 [英] "No identifier/primary key specified for Entity" - extends FOS User
问题描述
致命错误:未捕获异常'Doctrine\ORM\Mapping消息无标识符/为主体指定的主键的\MappingExceptionWisJa\CoreBundle\Entity\User子类FOS\UserBundle\Model\User。每个实体必须有一个标识符/主键。在...
我的用户实体所有代码:
<?php
命名空间WisJa\CoreBundle\Entity;
使用Doctrine\ORM\Mapping作为ORM;
使用FOS\UserBundle\Model\User作为BaseUser;
/ **
* @ ORM\Table(name =fos_user)
* @ ORM\Entity
* /
类用户扩展BaseUser
{
/ **
* @var整数
*
* @ ORM\Column(name =id,type =integer)
* @ ORM\Id
* @ ORM\GeneratedValue(strategy =AUTO)
* /
protected $ id;
/ **
* @var string
*
* @ ORM\Column(name =facebook,type =string,nullable = true ,length = 255)
* /
protected $ facebook;
public function __construct()
{
parent :: __ construct();
//你自己的逻辑
}
/ **
*获取id
*
* @return integer
* /
public function getId()
{
return $ this-> id;
}
/ **
*设置Facebook
*
* @param string $ facebook
* @return用户
* /
public function setFacebook($ facebook)
{
$ this-> facebook = $ facebook;
return $ this;
}
/ **
*获取Facebook
*
* @return string
* /
public function getFacebook( )
{
return $ this-> facebook;
}
}
我不知道为什么它在本地主机上工作,但是
您需要清除完整的缓存
dir在您的托管。
I have UserBundle who extends FOSUserBundle, and entity User who extends FOS's User class. On my localhost work fine, but on hosting i've got error:
Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'No identifier/primary key specified for Entity "WisJa\CoreBundle\Entity\User" sub class of "FOS\UserBundle\Model\User". Every Entity must have an identifier/primary key.' in...
My User entity all code:
<?php
namespace WisJa\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Model\User as BaseUser;
/**
* @ORM\Table(name="fos_user")
* @ORM\Entity
*/
class User extends BaseUser
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
*
* @ORM\Column(name="facebook", type="string", nullable=true, length=255)
*/
protected $facebook;
public function __construct()
{
parent::__construct();
// your own logic
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set facebook
*
* @param string $facebook
* @return User
*/
public function setFacebook($facebook)
{
$this->facebook = $facebook;
return $this;
}
/**
* Get facebook
*
* @return string
*/
public function getFacebook()
{
return $this->facebook;
}
}
I have no idea why it works on localhost but don't works in web...
You need to clear the fully cache
dir at your hosting.
这篇关于“没有为实体指定的标识符/主键” - 扩展FOS用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!