解决这个问题的另一个解决方案是:
public function findAllExcepcionesByItem($itemId) { $query = $this->createQueryBuilder('p') ->leftJoin('p.item', 'i') ->where("i.id = :actual")->setParameter("actual", $itemId) ->andWhere("p.excepcion != ''") // NOT EMPTY ->andWhere("p.excepcion IS NOT NULL") // NOT NULL ->getQuery(); return $query->getResult(); }