oneToMany / ManyToOne双向关联不在doctrine2中生成连接列

时间:2012-06-07 18:41:16

标签: symfony doctrine doctrine-orm

我正在尝试为一个表创建两个oneToMany关系。但是,当我生成enities时,不会在Foo实体上生成连接列。这是我的yaml:

User.orm.yml

Acme\SomeBundle\Entity\User:
  type: entity
  table: user
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    firstname:
      type: string
      length: 40
    created_at:
      type: datetime
      gedmo:
        timestampable:
          on: create
    updated_at:
      type: datetime
      gedmo:
        timestampable:
          on: update
  oneToMany:
    foos:
      targetEntity: Foo
      mappedBy: user

Artist.orm.yml

Acme\SomeBundle\Entity\Artist:
  type: entity
  table: artist
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    name:
      type: string
      length: 100
  oneToMany:
    foos:
      targetEntity: Foo
      mappedBy: artist

Foo.orm.yml

Acme\SomeBundle\Entity\Foo:
  type: entity
  table: foo
  id:
    id:
      type: integer
      generator:
        strategy: AUTO
  fields:
    created_at:
      type: datetime
      gedmo:
        timestampable:
          on: create
    updated_at:
      type: datetime
      gedmo:
        timestampable:
          on: update
  ManyToOne:
    artist:
      targetEntity: Artist
      inversedBy: foos
    user:
      targetEntity: User
      inversedBy: foos

在Foo Table上只创建id,created_at和updated_at列,同时还应创建两个连接列。我还试图在我的yaml文件中手动定义连接列,但是the docs说这不应该是必要的。

任何人都有线索?

1 个答案:

答案 0 :(得分:0)

Pfff原来是ManyToMany上的首都M.应为manyToMany