我在我的实体中建立了一对多的关系。当尝试获取相关行集时,它会带来空结果,当尝试从子实体中查找父行时,它会抛出Entity was not found异常
这是我的 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');
这是我的关系
/**
* @var array $userFacebooks
*
* @OneToMany(targetEntity="Application_Model_UserFacebook", mappedBy="user")
*/
protected $userFacebooks;
和父母之一
/**
* @ManyToOne(targetEntity="Application_Model_User", inversedBy="userFacebooks")
* @JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;