0
我有两个实体,联系人和全局。学说实体缺少分配的ID
Example\EventBundle\Entity\EventGlobal:
type: entity
table: EventGlobal
fields:
id:
id: true
type: integer
generator:
strategy: AUTO
oneToOne:
EventKontakt:
targetEntity: Example\EventBundle\Entity\EventContact
mappedBy: EventGlobal
cascade: ["persist"]
Example\EventBundle\Entity\EventContact:
type: entity
table: EventContact
fields:
EventGlobal_id:
id: true
type: integer
oneToOne:
EventGlobal:
targetEntity: Example\EventBundle\Entity\EventGlobal
inversedBy: EventContact
joinColumns:
EventGlobal_id:
referencedColumnName: id
nullable: false
他们工作正常。现在我用Symfony构建一个表格
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add(Stuff..)
->add('EventContact', new EventContactType($this->options))
;
}
表单被正确渲染,并且具有一对一的关系。 但是,当我保存我得到一个错误。
,我的错误是:
Entity of type Example\EventBundle\Entity\EventContact is missing an assigned ID. The identifier generation strategy for this entity requires the ID field to be populated before EntityManager#persist() is called. If you want automatically generated identifiers instead you need to adjust the metadata mapping accordingly.
我怎样才能achive我后的安全是由Symfony的/学说做了什么?
它的工作部分,如果我只产生一个eventglobal没有eventcontact一次,然后返回生成这两个ID是坏了,并链接到最后一个条目。 – Tny 2012-04-06 23:27:15