Repository/CategoryRepository.php
public function getHome()
    {
        $query = $this->createQueryBuilder('c')
            ->join('c.forums', 'f')
            ->join('f.lastMessage', 'm')
            ->join('m.user', 'u')
            ->addSelect('f')
            ->addSelect('m')
            ->addSelect('u')
            ->where('f.status = :status')
            ->setParameter('status', Forum::STATUS_PUBLIC);

        $query->orderBy('c.position', 'ASC')
            ->addOrderBy('f.position', 'ASC');


        return $query->getQuery();
    }
public function getHome()
    {
        $query = $this->createQueryBuilder('c')
            ->join('c.forums', 'f')
            ->join('f.lastMessage', 'm')
            ->join('m.user', 'u')
            ->addSelect('f')
            ->addSelect('m')
            ->addSelect('u')
            ->where('f.status = :status')
            ->setParameter('status', Forum::STATUS_PUBLIC);

        $query->orderBy('c.position', 'ASC')
            ->addOrderBy('f.position', 'ASC');


        return $query->getQuery();
    }
Finds category with forum


@return \Doctrine\ORM\Query