2016-08-15 66 views
0

我创建了扩展FOSOAuthServerBundle的客户端。此客户端的代码如下:实体'Acme ApiBundle Entity Client'的列'random_id'在字段或鉴别器列映射中的重复定义

<?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; 
    } 
} 

所以,正如我所说,我向它有$ randomId的FOSOAuthServerBundle(\ friendsofsymfony \ OAuth的服务器捆绑\实体\ Client.php,第28行)。现在我收到一个错误:

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.

我在哪里出错了?

回答

0

当我使用FOS\OAuthServerBundle\Entity\Client时,我使用了扩展另一个目标类(FOS\OAuthServerBundle\Model\Client)的类。有目标变量,例如我发现的$ RandomId dublicate。所以,根据我的意见,因为Acme\ApiBundle\Entity\Client延伸FOS\OAuthServerBundle\Entity\Client其中延伸FOS\OAuthServerBundle\Model\Client,我们得到的变量两次而不是一次。所以我决定直接扩展FOS\OAuthServerBundle\Model\Client,它解决了我的问题。任何人都可以解释为什么以这种方式做代码是不可能的吗?

相关问题