protected function addJoinTablesToQueryBuilder(QueryBuilder $queryBuilder)
    {
        $objectManager = $this->getObjectManager();
        $entityAlias   = $this->getEntityClassAlias();
        $classMetaData = $objectManager->getClassMetadata($this->getEntityClass());

        $assocMappings = $classMetaData->getAssociationMappings();

        foreach ($assocMappings as $fieldName => $assocMapping) {
            $join  = $entityAlias . '.' . $fieldName;
            $alias = self::JOIN_ALIAS_PREFIX . $fieldName;

            $queryBuilder->addSelect($alias);
            $queryBuilder->leftJoin($join, $alias);
        }
    }
protected function addJoinTablesToQueryBuilder(QueryBuilder $queryBuilder)
    {
        $objectManager = $this->getObjectManager();
        $entityAlias   = $this->getEntityClassAlias();
        $classMetaData = $objectManager->getClassMetadata($this->getEntityClass());

        $assocMappings = $classMetaData->getAssociationMappings();

        foreach ($assocMappings as $fieldName => $assocMapping) {
            $join  = $entityAlias . '.' . $fieldName;
            $alias = self::JOIN_ALIAS_PREFIX . $fieldName;

            $queryBuilder->addSelect($alias);
            $queryBuilder->leftJoin($join, $alias);
        }
    }
protected function addJoinTablesToQueryBuilder ( QueryBuilder $ queryBuilder ) { $ objectManager = $ this -> getObjectManager ( ) ; $ entityAlias = $ this -> getEntityClassAlias ( ) ; $ classMetaData = $ objectManager -> getClassMetadata ( $ this -> getEntityClass ( ) ) ; $ assocMappings = $ classMetaData -> getAssociationMappings ( ) ; foreach ( $ assocMappings as $ fieldName => $ assocMapping ) { $ join = $ entityAlias . '.' . $ fieldName ; $ alias = self :: JOIN_ALIAS_PREFIX . $ fieldName ; $ queryBuilder -> addSelect ( $ alias ) ; $ queryBuilder -> leftJoin ( $ join , $ alias ) ; } }
Adds joins for all association mappings to the query builder

@param QueryBuilder $queryBuilder
Adds joins for all association mappings to the query builder