I have the following tables, where I have no problem in inserting, updating etc. But, how can I fetch the result rows for this kind of mapping?
Organizations
-->id
-->name
users
-->id
-->first_name
doctors
-->id
-->user_id
org_doctors
-->id
-->org_id
-->doctor_id
This is my OrgDoctor Entity:
<?php
namespace Doctor\Entity;
use Doctrine\ORM\Mapping as ORM;
use Library\Entity\BaseEntity;
use User\Entity\User;
use Doctor\Entity\Doctor;
use Organization\Entity\Organization;
/**
 * @ORM\Entity
 * @ORM\Table(name="org_doctors")
 */
class OrgDoctor extends BaseEntity{
    /**
     * @ORM\ManyToOne(targetEntity="Doctor\Entity\Doctor", inversedBy="orgDoctor")
     * @ORM\JoinColumn(name="doctor_id",referencedColumnName="id",nullable=false)
     */
    protected $doctor;
    /**
     * @ORM\ManyToOne(targetEntity="Organization\Entity\Organization", inversedBy="orgDoctor")
     * @ORM\JoinColumn(name="org_id", referencedColumnName="id", nullable=false)
     */
    protected $organization;
    public function setDoctor(Doctor $doctor = null)
    {
        $this->doctor = $doctor;
        return $this;
    }
    public function getDoctor()
    {
        return $this->doctor;
    } 
    public function setOrganization(Organization $organization = null)
    {
        $this->organization = $organization;
        return $this;
    }
    public function getOrganization()
    {
        return $this->organization;
    }    
}
And this is my Doctor Entity:
<?php
namespace Doctor\Entity;
use Library\Entity\BaseEntity;
use Users\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
 * @ORM\Entity
 * @ORM\Table(name="doctors")
 */
class Doctor extends BaseEntity {
    /**
     * @ORM\OneToOne(targetEntity="Users\Entity\User")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
     * @var Users\Entity\User
     */
    private $user;
    /**
     * @ORM\Column(name="summary", type="string")
     * @var string
     */
    private $summary;
    function getUser() {
        return $this->user;
    }
    function setUser(User $user) {
        $this->user = $user;
    }
     function getSummary() {
        return $this->summary;
    }
    function setSummary($summary) {
        $this->summary = $summary;
    }
}
This is how I'm fetching the result for a single doctor:
$doctor = $this->entityManager->find('Doctor\Entity\Doctor', (int) $doctorId);
How can I fetch rows from the OrgDoctor entity?
this is how i tried using queryBuilder:
$qb = $this->entityManager->createQueryBuilder();
        $qb->select('od', 'd', 'o')
            ->from('Doctor\Entity\OrgDoctor', 'od')
            ->join('od.organization', 'o')
            ->join('od.doctor', 'd')
            ->where('od.organization = :organization')
            ->setParameter('organization', $orgId);
        $query = $qb->getQuery();
        $results =  $query->getResult();
        var_dump($results);
 Notice: Undefined index: orgDoctor in C:\xampp\htdocs\corporate-wellness\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 125
In Organization Entity:
     /**
     * @ORM\OneToMany(targetEntity="Doctor\Entity\OrgDoctor", mappedBy="organization")
     */
    protected $orgDoctor;
 
     
    