简体   繁体   中英

oneToMany/ManyToOne bidirectional association not generating join columns in doctrine2

I'm trying to create two oneToMany relationships to one table. However, when I generate the enities, the join columns are not generate on the Foo entity. Here is my 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

Only the id, created_at and updated_at columns are created on the Foo Table while there should also be created two join columns. I have also tried to manually define the join columns in my yaml file, however the docs say that this shouldn't be neccesary.

Anyone got a clue?

Pfff turned out to be the capital M on ManyToMany . Should be manyToMany

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM