普通网友 2016-08-15 10:58
浏览 24
已采纳

在字段或鉴别器列映射中实体'Acme \ ApiBundle \ Entity \ Client'上的列'random_id'的重复定义

I created client which extends FOSOAuthServerBundle. The code of this client is the following:

<?php 
namespace Acme\ApiBundle\Entity;
use FOS\OAuthServerBundle\Entity\Client as BaseClient;
use Doctrine\ORM\Mapping as ORM;
 /**
 * Class Client
 *
 * @package Acme\ApiBundle\Entity
 *
 * @ORM\Table("oauth2_clients")
 * @ORM\Entity
 */
class Client extends BaseClient
{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
    protected $name;

    public function __construct()
    {
        parent::__construct();
    }
    public function setName($name)
    {
        $this->name = $name;
    }
    public function getName()
    {
        return $this->name;
   }
}

So, as I said, I extend the FOSOAuthServerBundle which has $randomId (\friendsofsymfony\oauth-server-bundle\Entity\Client.php, line 28). Now I get an error:

MappingException in MappingException.php line 565: Duplicate definition of column 'random_id' on entity 'Acme\ApiBundle\Entity\Client' in a field or discriminator column mapping.

Where did I a mistake?

  • 写回答

1条回答 默认 最新

  • dpfln86244 2016-08-15 14:45
    关注

    When I used FOS\OAuthServerBundle\Entity\Client, I used a class which extends another, target class (FOS\OAuthServerBundle\Model\Client). There were targeted variables, such as $RandomId which I found dublicate. So, according to my opinion, as Acme\ApiBundle\Entity\Client extends FOS\OAuthServerBundle\Entity\Client which extends FOS\OAuthServerBundle\Model\Client, we got variables twice instead of once. So I decided to extend FOS\OAuthServerBundle\Model\Client directly and it solves my issue. Can anyone explain why it is impossible to do code in a such way?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图