【问题标题】:No mapping found for field找不到字段的映射
【发布时间】:2013-01-08 19:25:26
【问题描述】:

我必须实体

class Patients 

    {
         /**
         * @ORM\OneToOne(targetEntity="ContactAddress", mappedBy="patients")
         */
        protected $contactaddress;
    }

还有一个

class ContactAddress
{
    /**
     * @ORM\OneToOne(targetEntity="Patients", inversedBy="contactaddress")
     * @ORM\JoinColumn(name="patient_id", referencedColumnName="id")
     */
     protected $patient;
}

当我尝试执行这段代码时

$em = $this->getDoctrine()->getEntityManager();
$product = $em->getRepository('SurgeryPatientBundle:Patients')->find($id);

我明白了

No mapping found for field 'patients' on class 'Surgery\PatientBundle\Entity\ContactAddress'. 

当我尝试访问联系人存储库时,我得到了结果

请帮忙 ;D 对不起我的英语

【问题讨论】:

    标签: entity-framework symfony orm doctrine mapping


    【解决方案1】:

    您必须在 ContactAddress 实体中引用 patient 而不是患者*s*。

    class Patients 
    {
         /**
         * @ORM\OneToOne(targetEntity="ContactAddress", mappedBy="patient")
         */
        protected $contactaddress;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-21
      • 2018-07-29
      • 2014-10-13
      • 1970-01-01
      相关资源
      最近更新 更多