Joe*_*oco 3 mapping validation one-to-many many-to-one doctrine-orm
class Account
{
...
/*
* @OneToMany(targetEntity="Address", mappedBy="account");
*/
private $addresses;
...
}
class Address
{
...
/**
* @ManyToOne(targetEntity="Account", inversedBy="addresses")
* @JoinColumn(name="account_id", referencedColumnName="id")
*/
private $account;
...
}
Run Code Online (Sandbox Code Playgroud)
当我运行console命令来验证模式时:
[Mapping] FAIL - 实体类'Entity\Address'映射无效:*关联Entity\Address#account指的是不存在的反面字段Entity\Account#地址
为什么?
我认为Doctrine注释阅读器使用php的Reflection API,专门getDocComment用于阅读注释.这意味着您的文档块注释必须以/**其他方式开始,否则将被忽略.您的$addresses属性注释开头,/*因此它不会被拾取.