Symfony2唯一约束已在使用中

时间:2013-04-11 14:31:45

标签: symfony doctrine-orm

我的UserTrack实体

/**
 * @ORM\Entity(repositoryClass="JJ\MainBundle\Repository\UserTrackRepository")
 * @ORM\Table
 * @UniqueEntity({"user", "track"})
 * @JMS\ExclusionPolicy("all")
 */
class UserTrack implements RateableInterface
...
    /**
     * @ORM\ManyToOne(targetEntity="JJ\MainBundle\Entity\User", inversedBy="user_tracks", fetch="EXTRA_LAZY")
     */
    protected $user;
...
    /**
     * @ORM\ManyToOne(targetEntity="JJ\MainBundle\Entity\Track", inversedBy="user_tracks")
     * @JMS\Expose
     */
    protected $track;
...

我打电话的时候:

$this->validator->validate($userTrack);

这是我的例外(当我更新我的实体时):

message": "JJ\\MainBundle\\Entity\\UserTrack.user:\n This value is already used.\n",

虽然我可以清楚地看到它是独一无二的: enter image description here

请赐教......

0 个答案:

没有答案