2014-05-15 3 views
0

3 개의 테이블을 만들고 싶습니다. 심포니 2와 독트린을 사용합니다. 확고한, 종류 및 종류 관계. 이 두 테이블에 manyToMany 관계가 있습니다.이 관계는 categoryRelation 테이블에 보관됩니다. 내 yml 매핑은;Doctrine2 연관 매핑 'ManyToMany'가 'targetEntity'속성을 누락했습니다. 예외

Firm: 
// other columns 
    ManyToMany: 
    categories: 
     targetEntity: Category 
     joinTable: 
     name: category_relation 
     joinColumns: 
      firm_id: 
      referencedColumnName: id 
     inverseJoinColumns: 
      category_id: 
      referencedColumnName: id 


Category: 
// other columns 
    manyToMany: 
    firms: 
    targetEntity: Firm 
    mappedBy: categories 

저에게이 오류 나는이 오류를 해결하려면 어떻게

The association mapping 'ManyToMany' misses the 'targetEntity' attribute. 

을 제공? 답변 주셔서 감사합니다

답변

2

코드를 예제 코드 http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html, 섹션 5.14와 비교했습니다. 다 대다, 양방향. 아래 코드를 붙여 넣습니다.

User: 
    type: entity 
    manyToMany: 
    groups: 
     targetEntity: Group 
     inversedBy: users 
     joinTable: 
     name: users_groups 
     joinColumns: 
      user_id: 
      referencedColumnName: id 
     inverseJoinColumns: 
      group_id: 
      referencedColumnName: id 

Group: 
    type: entity 
    manyToMany: 
    users: 
     targetEntity: User 
     mappedBy: groups 

나는 예외를 생성 할 수있는 몇 가지 차이점을 보았습니다. 첫째, 유형 : 엔티티 지시문을 작성하지 않습니다. 첫 번째 manyToMany 지시문은 대문자로 된 첫 번째 M을가집니다. inversedBy 지시문은 존재하지 않습니다. 그리고 마지막으로 나는 이것이 가장 큰 문제라고 생각이, 당신의 지시 targetEntity 및 mappedBy이 들여 쓰기되지 않습니다

firms: 
targetEntity: Firm 
mappedBy: categories 

을 그리고 YAML은 들여 쓰기를 기반으로, 따라서 아마도이 예외에 지정된 targetEntity입니다. 다음과 같이 작성해야합니다.

firms: 
    targetEntity: Firm 
    mappedBy: categories