From 514dd4e8528c47c47d97765ac041ce91d8147a36 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 26 Oct 2013 12:32:53 +0200 Subject: [PATCH] [DDC-2757] Update documentation with regard to manually closing the EntityManager when an Exception occurs. --- .../transactions-and-concurrency.rst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/en/reference/transactions-and-concurrency.rst b/docs/en/reference/transactions-and-concurrency.rst index 1b06156e9..4dc18318e 100644 --- a/docs/en/reference/transactions-and-concurrency.rst +++ b/docs/en/reference/transactions-and-concurrency.rst @@ -70,7 +70,6 @@ looks like this: $em->getConnection()->commit(); } catch (Exception $e) { $em->getConnection()->rollback(); - $em->close(); throw $e; } @@ -81,14 +80,12 @@ require an active transaction. Such methods will throw a ``TransactionRequiredException`` to inform you of that requirement. -A more convenient alternative for explicit transaction demarcation -is the use of provided control abstractions in the form of -``Connection#transactional($func)`` and -``EntityManager#transactional($func)``. When used, these control -abstractions ensure that you never forget to rollback the -transaction or close the ``EntityManager``, apart from the obvious -code reduction. An example that is functionally equivalent to the -previously shown code looks as follows: +A more convenient alternative for explicit transaction demarcation is the use +of provided control abstractions in the form of +``Connection#transactional($func)`` and ``EntityManager#transactional($func)``. +When used, these control abstractions ensure that you never forget to rollback +the transaction, in addition to the obvious code reduction. An example that is +functionally equivalent to the previously shown code looks as follows: .. code-block:: php @@ -104,8 +101,8 @@ previously shown code looks as follows: The difference between ``Connection#transactional($func)`` and ``EntityManager#transactional($func)`` is that the latter abstraction flushes the ``EntityManager`` prior to transaction -commit and also closes the ``EntityManager`` properly when an -exception occurs (in addition to rolling back the transaction). +commit and rolls back the transaction when an +exception occurs. Exception Handling ~~~~~~~~~~~~~~~~~~