An user has one role. A role has zero or many users.
I would like to find roles without users.
I need to have this query without using IN or NOT IN
You can find roles that don't have any users by using a count query
$qb = $this->createQueryBuilder('role'); $qb ->addSelect('COUNT(users.id) AS total_users') ->leftJoin('role.users', 'users') ->groupBy('role.id') ->having('total_users = 0') ->getQuery()->getResult();