QueryResultCollection is unaware of primarySelector that was set for a query. It has to be aware of primarySelector because it's using PHPCR-ODM's Row::getNode() method where primarySelector is required to work properly for queries that have SQL joins.
Because of this issue it is impossible to use SQL joins in queries generated by DocumentManager::createQuery().
I look forward to elaborate this issue further and possibly create a PR soon. Meanwhile, reflection can be used as a temporary solution to set primarySelector:
$query = $documentManager->createQuery(...);
$result = $query->execute();
$reflection = new \ReflectionProperty(get_class($result), 'primarySelector');
$reflection->setAccessible(true);
$reflection->setValue($result, 'i'); //put your primarySelector as a 2nd parameter
QueryResultCollection is unaware of primarySelector that was set for a query. It has to be aware of primarySelector because it's using PHPCR-ODM's Row::getNode() method where primarySelector is required to work properly for queries that have SQL joins.
Because of this issue it is impossible to use SQL joins in queries generated by DocumentManager::createQuery().
I look forward to elaborate this issue further and possibly create a PR soon. Meanwhile, reflection can be used as a temporary solution to set primarySelector: