我在yaml中的文档中使用了One-To-Many,Unidirectional with Join Table关联,但是在数据库中没有创建唯一约束。
我正在使用postgres。我做错了什么?
这是我的实体,它有两个“一对多,单向连接表”关联“问题”和“答案”
TestCasesPersistence\Entities\GroupQA:
type: entity
table: group_qa
id:
id:
type: integer
nullable: false
length: null
fixed: false
id: true
column: id
generator:
strategy: IDENTITY
fields:
name:
type: string
nullable: true
length: null
fixed: false
column: name
timeCreated:
type: datetime
nullable: true
column: time_created
manyToMany:
questions:
targetEntity: Question
joinTable:
name: group_qa_questions
joinColumns:
group_qa_id:
referencedColumnName: id
inverseJoinColumns:
question_id:
unique: true
referencedColumnName: id
answers:
targetEntity: Answer
joinTable:
name: group_qa_answers
joinColumns:
group_qa_id:
referencedColumnName: id
inverseJoinColumns:
answer_id:
unique: true
referencedColumnName: id
typeSearches:
targetEntity: TypeSearch
joinTable:
name: group_qa_type_searches
joinColumns:
group_qa_id:
referencedColumnName: id
inverseJoinColumns:
type_search_id:
referencedColumnName: id
lifecycleCallbacks: { }
文档http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html
第5.6节
答案 0 :(得分:0)
我在“回答”和“问题”分析的yaml配置中有一个错误
正确的方式:
manyToMany:
questions:
targetEntity: Question
joinTable:
name: group_qa_questions
joinColumns:
group_qa_id:
referencedColumnName: id
inverseJoinColumns:
question_id:
unique: true
referencedColumnName: id
answers:
targetEntity: Answer
joinTable:
name: group_qa_answers
joinColumns:
group_qa_id:
referencedColumnName: id
inverseJoinColumns:
answer_id:
unique: true
referencedColumnName: id