diff --git a/doctrine/associations.rst b/doctrine/associations.rst index 5760509030b..b34acddd3bd 100644 --- a/doctrine/associations.rst +++ b/doctrine/associations.rst @@ -381,11 +381,7 @@ following method to the ``ProductRepository`` class:: WHERE p.id = :id' )->setParameter('id', $productId); - try { - return $query->getSingleResult(); - } catch (\Doctrine\ORM\NoResultException $exception) { - return null; - } + return $query->getOneOrNullResult(); } Now, you can use this method in your controller to query for a ``Product``