2015-12-21 56 views
3
「價值」 隨機獨特的價值

我定義這個夾具:無法生成在128次嘗試

Clanmovil\PlatformBundle\Entity\Alias: 
    alias_{1..500}: 
     name (unique): Alias_<numberBetween(1, 500)> 
     description: <text(150)> 
     active: <boolean(31)> 
     createdAt: <dateTimeThisYear()> 
     updatedAt: <dateTimeThisYear()> 

而且我在控制檯收到此錯誤:

[RuntimeException的] Couldn不會爲Clanmovil \ PlatformBundle \ Entity \ Alias:128個嘗試中的名稱生成隨機唯一值。

我在捆綁的源代碼上通過這個錯誤做了一點研究,但我不清楚問題可能是什麼。這裏有什麼問題?當我發現像這樣的問題時,我該怎麼做?

如果這種幫助是這種實體的樣子:

namespace Clanmovil\PlatformBundle\Entity; 

use Doctrine\ORM\Mapping as ORM; 
use Clanmovil\PlatformBundle\Model\IdentifierAutogeneratedTrait; 
use Symfony\Component\Validator\Constraints as Assert; 
use Gedmo\Timestampable\Traits\TimestampableEntity; 

/** 
* @ORM\Entity 
* @ORM\Table(name="cm_alias", 
*  uniqueConstraints={@ORM\UniqueConstraint(name="name", columns={"name"})}, 
     indexes={@ORM\Index(name="fulltext_idx", 
      columns={"name"}, 
      flags={"fulltext"})}) 
*) 
*/ 
class Alias 
{ 
    use IdentifierAutogeneratedTrait; 
    use TimestampableEntity; 

    /** 
    * @var string 
    * @ORM\Column(type="string", length=150) 
    * @Assert\NotBlank() 
    */ 
    protected $name; 

    /** 
    * @var string 
    * @ORM\Column(type="text", nullable=true) 
    */ 
    protected $description; 

    /** 
    * @var bool 
    * @ORM\Column(type="boolean") 
    */ 
    protected $active = true; 

    /** 
    * @ORM\ManyToMany(targetEntity="Command", mappedBy="command_alias", cascade={"persist"}) 
    */ 
    protected $alias_command; 


    /** 
    * Set name. 
    * 
    * @param string $name 
    * @return Alias 
    */ 
    public function setName($name) 
    { 
     $this->name = $name; 

     return $this; 
    } 

    /** 
    * Get name. 
    * 
    * @return string 
    */ 
    public function getName() 
    { 
     return $this->name; 
    } 

    /** 
    * Set description. 
    * 
    * @param string $description 
    * 
    * @return Alias 
    */ 
    public function setDescription($description) 
    { 
     $this->description = $description; 

     return $this; 
    } 

    /** 
    * Get description. 
    * 
    * @return string 
    */ 
    public function getDescription() 
    { 
     return $this->description; 
    } 

    /** 
    * Set active. 
    * 
    * @param bool $active 
    * 
    * @return Category 
    */ 
    public function setActive($active) 
    { 
     $this->active = $active; 

     return $this; 
    } 

    /** 
    * Get active. 
    * 
    * @return bool 
    */ 
    public function getActive() 
    { 
     return $this->active; 
    } 

    /** 
    * Get command for alias 
    * 
    * @return string 
    */ 
    public function getAliasCommand() 
    { 
     return $this->alias_command; 
    } 

    public function __toString() 
    { 
     return $this->name; 
    } 

} 

回答

2

我不知道這是最好的解決方案,但到目前爲止,我有固定的只是增加了隨機數的數量問題:

name (unique): Alias_<numberBetween(1, 1000)> 
相關問題