2

I made one to many relation in my entities. when try to get related rowset it brings empty result and when try to find parent row from child entity it throws Entity was not found exception

here is my initDoctrine

$classLoader = new \Doctrine\Common\ClassLoader(
                        'Doctrine',
                        APPLICATION_PATH . '/../library/'
        );
        $classLoader->register();
        $config = new \Doctrine\ORM\Configuration();
        $cache = new \Doctrine\Common\Cache\ArrayCache;
        $config->setMetadataCacheImpl($cache);
        $config->setQueryCacheImpl($cache);
        $driver = $config->newDefaultAnnotationDriver(array(APPLICATION_PATH . '/models'));
        $config->setMetadataDriverImpl($driver);
        $config->setProxyDir(APPLICATION_PATH . '/../bin/tmp/Proxies');
        $config->setProxyNamespace('App\Proxies');
        $config->setAutoGenerateProxyClasses(true);
        $connectionSettings = $this->getOption('doctrine');

here are my relations

/**
* @var array $userFacebooks
* 
* @OneToMany(targetEntity="Application_Model_UserFacebook", mappedBy="user")
*/
protected $userFacebooks;

and the parent one

/**
* @ManyToOne(targetEntity="Application_Model_User", inversedBy="userFacebooks")
* @JoinColumn(name="user_id", referencedColumnName="id") 
*/
protected $user;

1 Answers1

0

The mappings look ok. Check that all your entity classes are annotated with:

/**
 * @entity
 */
class Entity_Name { ... }
Ivan Pintar
  • 1,861
  • 1
  • 15
  • 27