I have the following problem. This is probably a misunderstanding. But after searching the Internet for hours, not finding a solution, I post it here.
I have my own request in Doctrine:
$rsm = new ResultSetMapping;
$rsm->addEntityResult('Acme\CommentBundle\Entity\Comment', 'c');
$rsm->addFieldResult('c', 'comment_id', 'id');
$rsm->addFieldResult('c', 'slug', 'slug');
$rsm->addFieldResult('c', 'comment', 'comment');
$rsm->addFieldResult('c', 'created', 'created');
$rsm->addJoinedEntityResult('Acme\AccountBundle\Entity\Worker', 'w', 'c', 'komments');
$rsm->addFieldResult('w', 'worker_id', 'id');
$rsm->addFieldResult('w', 'worker_name', 'name');
$rsm->addJoinedEntityResult('Acme\CommentBundle\Entity\Document', 'd', 'c', 'documents');
$rsm->addFieldResult('d', 'document_id', 'id');
$rsm->addFieldResult('d', 'document_name', 'name');
return $this->getEntityManager()
->createNativeQuery('SELECT t.id, c.id AS comment_id, c.slug, c.created, c.comment, c.worker_id AS comment_worker_id, c.created AS comment_created, d.id AS document_id, d.name AS document_name, w.id AS worker_id, w.name AS worker_name
FROM comment_thread t
INNER JOIN project p ON p.comment_thread_id = t.id
LEFT JOIN comment c ON t.id = c.thread_id
INNER JOIN worker w ON c.worker_id = w.id
LEFT JOIN comment_document d ON c.id = d.comment_id
WHERE p.id = :project_id
ORDER BY c.created ASC', $rsm)
->setParameter('project_id', $
Unfortunately, the first addJoinedEntityResult (working) does not work. If I delete it, the rest of addJoinedEntityResult (Document) is just fine.
I assume this is due to the fact that the Document is associated with a comment. Thus, the comment is the "parent" of the document. In the case of the Worker, this is the opposite: The comment is the "child" of the Worker, and not the "parent", as for the document.
In other words: - An employee may have several comments - A comment may contain several documents
"" , () (0.. n) .
Doctrine?
: -)
Nicki