繁体   English   中英

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

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

我正在尝试为一个表创建两个oneToMany关系。 但是,当我生成实体时,不会在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表上仅创建id,created_at和Updated_at列,同时还应创建两个连接列。 我也尝试过在yaml文件中手动定义连接列,但是文档说这不应该是必需的。

有人知道了吗?

Pfff原来是ManyToMany上的大写M。 应该manyToMany

暂无
暂无

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

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