2012-10-31 47 views
1

FOSUserBundle邀请函的安装已按手册完成。
从表面上看,它确实有效。
但是,分析器显示映射错误。
我认为'inversedBy'的设置是按照手册中的规定设置的。
你如何看待它?Symfony2 FOSUserBundle邀请函:'inversedBy'映射错误

实体

/** @ORM\Entity */ 
class Invitation 
{ 
    /** 
    * @ORM\OneToOne(targetEntity="User", inversedBy="invitation", cascade={"persist", "merge"}) 
    */ 
    protected $user; 

    // ... 

/** 
* @ORM\Entity 
* @ORM\Table(name="fos_user") 
*/ 
class User extends \FOS\UserBundle\Entity\User 
{ 
    /** 
    * @ORM\OneToOne(targetEntity="Invitation", inversedBy="user") 
    * @ORM\JoinColumn(referencedColumnName="code") 
    * @Assert\NotNull(message="Your invitation is wrong") 
    */ 
    protected $invitation; 

    // ... 

探查

FOS\UserBundle\Entity\User Valid 

My\SampleBundle\Entity\User 
The field My\SampleBundle\Entity\User#invitation is on the owning side of a bi-directional 
relationship, but the specified mappedBy association 
    on the target-entity My\SampleBundle\Entity\Invitation# does not contain 
    the required 'inversedBy' attribute. 

My\SampleBundle\Entity\Invitation 
The field My\SampleBundle\Entity\Invitation#user is on the owning side of a bi-directional 
relationship, but the specified mappedBy association 
    on the target-entity My\SampleBundle\Entity\User# does not contain 
    the required 'inversedBy' attribute. 

回答

0

根据参考http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html逆侧(在这种情况下邀请)必须是指用户为 “的mappedBy”,而不是 “inversedBy”。尝试

class Invitation 
{ 
    /** 
    * @ORM\OneToOne(targetEntity="User", mappedBy="invitation", cascade={"persist", "merge"}) 
    */ 
    protected $user; 

    // ... 
+0

哦....非强制性错误...我完全忽略了。谢谢你的建议。 – JIGEN