2
我使用Symfony2與教條,除了一個多對一/一對多的自引用關係外沒有關係問題。Doctrine2多對一自我引用:父母不生成
我有一個實體客戶可以有零個,一個或多個實體(也是客戶)。當我使用'doctrine:generate:entities BundleName'生成實體時,我的Entity Customer.php中只有一個var'$ entities',並且沒有var'$ mother_house'。此外,生成的遷移(使用doctrine:migrations:diff)不包含創建新字段'mother_house_id'。
在Customer.orm.yml的模式是這樣的一個:
Acme\Bundle\CustomerBundle\Entity\Customer:
type: entity
table: customer
repositoryClass: Acme\Bundle\CustomerBundle\Entity\CustomerRepository
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
company_name:
type: string
length: 255
reference:
type: string
length: '20'
created_at:
type: datetime
oneToMany:
entities:
targetEntity: Customer
mappedBy: mother_house
manyToOne:
mother_house:
targetEntity: Customer
inversedBy: entities
joinColumn:
mother_house_id:
referencedColumnName: id
manyToOne:
created_by:
targetEntity: Acme\Bundle\UserBundle\Entity\User
joinColumn:
created_by:
referencedColumnName: id
lifecycleCallbacks: { }