public function findByCompetency(Competency $competency)
    {
        return $this->createQueryBuilder('a')
            ->select(
                'a.id',
                'a.name',
                'a.resourceCount',
                'a.minResourceCount',
                'c.id AS competencyId',
                'l.name AS levelName',
                'l.value AS levelValue'
            )
            ->join('a.competencyAbilities', 'ca')
            ->join('ca.competency', 'c')
            ->join('ca.level', 'l')
            ->where('c.root = :root')
            ->andWhere('c.lft >= :lft')
            ->andWhere('c.rgt <= :rgt')
            ->orderBy('l.value, a.id')
            ->setParameters([
                ':root' => $competency->getRoot(),
                ':lft' => $competency->getLeft(),
                ':rgt' => $competency->getRight(),
            ])
            ->getQuery()
            ->getArrayResult();
    }