public function deleteOrphans()
    {
        $linkedAbilityIds = $this->_em->createQueryBuilder()
            ->select('a.id')
            ->distinct()
            ->from('HeVinci\CompetencyBundle\Entity\CompetencyAbility', 'ca')
            ->join('ca.ability', 'a')
            ->getQuery()
            ->getScalarResult();

        $qb = $this->createQueryBuilder('a')->delete();

        if (count($linkedAbilityIds) > 0) {
            $linkedAbilityIds = array_map(function ($element) {
                return $element['id'];
            }, $linkedAbilityIds);
            $qb->where($qb->expr()->notIn('a.id', $linkedAbilityIds));
        }

        $qb->getQuery()->execute();
    }