/** * @param \Kdyby\Persistence\Query|\Kdyby\Doctrine\QueryObject $queryObject * * @throws InvalidStateException * @throws QueryException * @return object|NULL */ public function fetchOne(Persistence\Query $queryObject) { try { return $queryObject->fetchOne($this); } catch (Doctrine\ORM\NoResultException $e) { return NULL; } catch (Doctrine\ORM\NonUniqueResultException $e) { // this should never happen! throw new InvalidStateException("You have to setup your query calling ->setMaxResult(1).", 0, $e); } catch (\Exception $e) { throw $this->handleQueryException($e, $queryObject); } }