我有两个实体:面试和评论。面试与评论有一对多的单向关系。学说2:无法正确设置一对多关系
这里是我的评论YAML映射文件:
Entities\Comment:
type: entity
table: Comment
repositoryClass: Repositories\CommentRepository
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
parentid:
type: integer
nullable: false
column: parentid
isactive:
type: integer
nullable: false
column: isactive
isremoved:
type: integer
nullable: false
column: isremoved
removaldate:
type: datetime
nullable: true
column: removaldate
user_name:
type: string
length: 255
nullable: false
column: user_name
user_email:
type: string
length: 255
nullable: false
column: user_email
user_avatar:
type: string
length: 255
nullable: false
column: user_avatar
comment:
type: text
nullable: false
column: comment
creationdate:
type: datetime
nullable: false
column: creationdate
rating:
type: integer
nullable: false
这里是我的YAML映射文件专访:
Entities\Interview:
type: entity
table: Interview
repositoryClass: Repositories\InterviewRepository
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
isremoved:
type: integer
nullable: false
column: isremoved
removaldate:
type: datetime
nullable: true
column: removaldate
creationdate:
type: datetime
nullable: false
column: creationdate
rating:
type: integer
nullable: false
anonstitle:
type: string
length: 1000
nullable: false
column: anonstitle
anons:
type: text
nullable: false
column: anons
anonsphoto:
type: string
length: 255
nullable: true
column: anonsphoto
interviewtitle:
type: string
length: 1000
nullable: false
column: interviewtitle
interview:
type: text
nullable: true
column: interview
interviewphoto:
type: string
length: 255
nullable: true
column: interviewphoto
manyToMany:
comments:
targetEntity: Comment
joinTable:
name: interviews_comments
joinColumns:
interview_id:
referencedColumnName: id
inverseJoinColumns:
comment_id:
referencedColumnName: id
unique: true
所以加载架构数据库后,我有3个表。其中2个是实体表,一个是关系,它只有2个列:interview_id,comment_id。但是在为某些面试保留Comment对象之后,我没有看到任何连接表。找不到原因。
无论您遇到问题,请张贴控制器代码,更新或创建操作。 – Lighthart 2013-03-21 20:24:56