教义2个具有一对多关系的实体
|
我正在尝试获取具有一对多关系的注释,但是一旦使用联接,我将得到以下数据:
entities\\Topic
id = 1 // integer
title = \"example\" // string
comments // entities\\Comment = oneToMany
id = 1 // integer
comment = \"first comment\" // string
topic // entities\\Topic = manyToOne
id = 1 // again..
title = \"example\"
当我加入主题评论时,为什么学说会获取评论内部的manyToOne关系?这是我的查询:
$this->em->createQueryBuilder()
->from(\'Entities\\Topic\', \'t\')
->select(\"t, c\")
->leftjoin(\"t.comments\", \'c\')
->where(\'t.id = :id\')
->setParameter(\'id\', 1)
->getQuery()->getSingleResult();
主题属性不应该为null或至少为空的arrayCollection吗?
另一件事:
当我指定评论为arrayCollection时,为什么将PersistentCollection作为评论返回?在我可以遍历PersistentCollection之前,是否总是需要对它使用unwrap?
没有找到相关结果
已邀请:
1 个回复
惜堡沁戚