考虑示例实体:
class Entity
{
/**
* @Id
* @OneToOne(targetEntity="AppBundle\Entity\User")
*/
public $user;
}
如何以XML保存此映射?
答案 0 :(得分:0)
知道了
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
https://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<entity name="AppBundle\Entity\Entity">
<id association-key="true" name="user" />
<one-to-one field="user" target-entity="AppBundle\Entity\User" />
</entity>
</doctrine-mapping>
关键部分是association-key="true"
,因此Doctrine不再抱怨已经拥有user
属性。