Category entity:

    public function __construct() {
        $this->candidates = new ArrayCollection();
    }
    
    public function getCandidates()
    {
        return $this->candidates;
    }
   
$metadata->mapManyToOne(array( 'fieldName' => 'candidates',
                               'targetEntity' => 'Entities\\Candidate',
                               'inversedBy' => 'category',
                               'joinColumns' => array( 0 => array( 'name' 
=> 'id',
                                                                  
 'referencedColumnName' => 'category_id',
                                                                  
 'nullable' => true,
                                                                  
 'columnDefinition' => NULL,
                                                      ), )
                             ));

--------------------------

Candidate entity:

    public function getCategory()
    {
         return $this->category;
    }
  
$metadata->mapManyToOne(array( 'fieldName' => 'category',
                               'targetEntity' => 'Entities\\Category',
                               'inversedBy' => 'candidates',
                               'joinColumns' => array( 0 => array( 'name' 
=> 'category_id',
                                                                  
 'referencedColumnName' => 'id',
                                                                  
 'nullable' => true,
                                                                  
 'columnDefinition' => NULL,
                                                      ), )
                             ));
---------------------------

The problem:
* Bug: Returns null., expected candidates assigned to one Category. DB is 
not empty.
$category = $em->getRepository('Entities\Category')->findOneBy(['id' => 1]);
$candidates = $category->getCandidates();
var_dump($candidates);

What mistake I did? I appreciate your help as I am stuck.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/doctrine-user/be75b6c6-8a67-46ee-a766-f9a4d47a630en%40googlegroups.com.

Reply via email to