|
4 | 4 | Transactions
|
5 | 5 | ============
|
6 | 6 |
|
7 |
| -.. default-domain:: mongodb |
8 |
| - |
9 | 7 | .. contents:: On this page
|
10 | 8 | :local:
|
11 | 9 | :backlinks: none
|
@@ -40,23 +38,24 @@ guarantees that the data involved in your transaction operations remains
|
40 | 38 | consistent, even if the operations encounter unexpected errors.
|
41 | 39 |
|
42 | 40 | When using the {+driver-short+}, you can create a new session from a
|
43 |
| -``Client`` instance as a ``ClientSession``. We recommend that you reuse |
| 41 | +``MongoClient`` instance as a ``ClientSession`` type. We recommend that you reuse |
44 | 42 | your client for multiple sessions and transactions instead of
|
45 | 43 | instantiating a new client each time.
|
46 | 44 |
|
47 | 45 | .. warning::
|
48 | 46 |
|
49 |
| - Use a ``Session`` only with the ``Client`` (or associated |
50 |
| - ``Database`` or ``Collection``) that created it. Using a |
51 |
| - ``Session`` with a different ``Client`` results in operation |
| 47 | + Use a ``ClientSession`` only with the ``MongoClient`` (or associated |
| 48 | + ``MongoDatabase`` or ``MongoCollection``) that created it. Using a |
| 49 | + ``ClientSession`` with a different ``MongoClient`` results in operation |
52 | 50 | errors.
|
53 | 51 |
|
54 | 52 | Methods
|
55 | 53 | -------
|
56 | 54 |
|
57 |
| -After you start a session by using the ``startSession()`` method, you can modify |
58 |
| -the session state by using the method set provided by the ``Session`` interface. |
59 |
| -The following table describes these methods: |
| 55 | +Create a ``ClientSession`` by using the ``startSession()`` method on your |
| 56 | +``MongoClient``instance. You can then modify the session state by using the |
| 57 | +methods provided by the ``ClientSession``. The following table details the |
| 58 | +methods you can use to manage your transaction: |
60 | 59 |
|
61 | 60 | .. list-table::
|
62 | 61 | :widths: 25 75
|
@@ -108,7 +107,8 @@ and commit a multi-document insert operation through the following steps:
|
108 | 107 |
|
109 | 108 | .. literalinclude:: /includes/fundamentals/code-snippets/Transaction.java
|
110 | 109 | :language: java
|
111 |
| - :start-after: end imports |
| 110 | + :start-after: start transaction |
| 111 | + :end-after: end transaction |
112 | 112 |
|
113 | 113 | If you require more control over your transactions, you can use the ``startTransaction()``
|
114 | 114 | method. This method allows you to explicitly commit or abort the transaction and manually
|
|
0 commit comments