em ->getRepository('\Company\Entity\CompanyRetail') ->findOneBy(array( 'company' => $jobRecord->company->id, 'retail' => $jobRecord->retail->id, 'archived' => false )); if (!is_null($duplicate)) { throw new \Exception('Found existing entry for this Retailer, only one account allowed per retailer.'); } } }