普通网友 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 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。