No mapping found for field

doctrine entity-framework mapping orm symfony

Question

I have to Entities

class Patients 

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

And another

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

When I try execute this code

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

I get

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

When i tried get to Contact repository I get result

Please Help ;D Sorry for my English

1
1
1/8/2013 7:35:42 PM

Accepted Answer

You must refer to patient instead of patient*s* in ContactAddress entity.

class Patients 
{
     /**
     * @ORM\OneToOne(targetEntity="ContactAddress", mappedBy="patient")
     */
    protected $contactaddress;
}
8
1/8/2013 7:48:56 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow