“在生成实体时,类的名称为'id'的字段覆盖无效”

时间:2014-07-30 14:42:58

标签: symfony doctrine-orm

如何创建具有适用于生成:实体的继承的mapping.yaml'命令?我试过这样:

Acme\EdgarMainBundle\Entity\Address:
  type: entity
  table: address
  repositoryClass: AddressRepository
  id:
    id:
      type: integer
      autoincrement: true
      generator:
        strategy: AUTO
  inheritanceType: SINGLE_TABLE
  discriminatorColumn:
    name: discr
    type: string
    length: 255
  discriminatorMap:
    customeraddress: Acme\MyBundle\Entity\Customeraddress
    corporationaddress: Acme\MyBundle\Entity\Corporationaddress
  fields:
    ...

Acme\MyBundle\Entity\Customeraddress:
  type: entity
  repositoryClass: CustomeraddressRepository
  fields:
    ...

Acme\MyBundle\Entity\Corporationaddress:
  type: entity
  repositoryClass: CorporationaddressRepository
  fields:
    ...

但我有一个错误:

Entity class 'Acme\MyBundle\Entity\Customeraddress' used in the discriminator map of class 'Acme\EdgarMainBundle\Entity\Address' does not exist. 

是的,我可以自己创建,但是有办法用

来创建它
doctrine:generate:entities MyBundle

命令?

1 个答案:

答案 0 :(得分:0)

doctrine:generate:entities MyBundle

应改为

doctrine:generate:entities AcmeMyBundle

doctrine:generate:entities Acme/MyBundle

文档:http://symfony.com/doc/current/book/doctrine.html#generating-getters-and-setters