2016-07-12 1 views
4

내 머리를 감쌀 수 없습니다. 나는 더 많거나 적은 튜토리얼에서 복사하지만, 프로파일 러는 두 가지 오류가 발생합니다 :doctrine : 존재하지 않는 사이드 필드 소유 (다시)를 말합니다

AppBundle \ 법인 \ 브랜드 이 AppBundle \ 엔티티 \ 장치 # 브랜드 소유 측 필드를 참조 협회 AppBundle \ 엔티티 \ 브랜드 # 장치를 어느 존재하지 않습니다. 연관 AppBundle \ 엔티티 \ 장치 # 브랜드 는 반대 측 필드 이없는 AppBundle \ 엔티티 \ 브랜드 # 브랜드 지칭

AppBundle \ 엔티티 \ 장치.

class Brand { 

    /** 
    * @var int 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

... 

    /** 
    * @ORM\OneToMany(targetEntity="Device", mappedBy="brands") 
    */ 
    private $devices; 
} 

class Device { 
    /** 
    * @var int 
    * @ORM\Id 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

... 

    /** 
    * @ORM\ManyToOne(targetEntity="Brand", inversedBy="devices") 
    * @ORM\JoinColumn(name="brand_id", referencedColumnName="id", nullable=true) 
    */ 
    private $brand; 
} 

답변

5

그것을 테스트하지 않은,하지만 문서에 따르면,이

http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/reference/association-mapping.html#one-to-many-bidirectional

class Brand { 

    /** 
    * @var int 
    * @ORM\Column(name="brand_id", type="integer") 
    * @ORM\Id 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

... 

    /** 
    * @ORM\OneToMany(targetEntity="Device", mappedBy="brand") 
    */ 
    private $devices; 
} 

처럼 보일 것이다
class Device { 
    /** 
    * @var int 
    * @ORM\Id 
    * @ORM\Column(name="id", type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    private $id; 

... 

    /** 
    * @ORM\ManyToOne(targetEntity="Brand", inversedBy="devices") 
    * @ORM\JoinColumn(name="brand_id", referencedColumnName="id", nullable=true) 
    */ 
    private $brand; 
} 
+0

음! 네가 옳아! 그래서 inversedBy 및 mappedBy 값은 테이블 이름이 아닙니까? – bluppfisk

+2

아니요, 내부 교리 문제입니다. http://stackoverflow.com/a/34583366/3275814 – lchachurski

+0

감사합니다. – bluppfisk

관련 문제