简体   繁体   English

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

[英]oneToMany/ManyToOne bidirectional association not generating join columns in doctrine2

I'm trying to create two oneToMany relationships to one table. 我正在尝试为一个表创建两个oneToMany关系。 However, when I generate the enities, the join columns are not generate on the Foo entity. 但是,当我生成实体时,不会在Foo实体上生成连接列。 Here is my yaml: 这是我的yaml:

User.orm.yml 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 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 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. 在Foo表上仅创建id,created_at和Updated_at列,同时还应创建两个连接列。 I have also tried to manually define the join columns in my yaml file, however the docs say that this shouldn't be neccesary. 我也尝试过在yaml文件中手动定义连接列,但是文档说这不应该是必需的。

Anyone got a clue? 有人知道了吗?

Pfff turned out to be the capital M on ManyToMany . Pfff原来是ManyToMany上的大写M。 Should be manyToMany 应该manyToMany

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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