@@ -165,8 +165,7 @@ strategy__. A transaction strategy is defined by the
165
165
----
166
166
public interface PlatformTransactionManager {
167
167
168
- TransactionStatus getTransaction(
169
- TransactionDefinition definition) throws TransactionException;
168
+ TransactionStatus getTransaction(TransactionDefinition definition) throws TransactionException;
170
169
171
170
void commit(TransactionStatus status) throws TransactionException;
172
171
@@ -200,16 +199,16 @@ execution.
200
199
201
200
The `TransactionDefinition` interface specifies:
202
201
203
- * __Isolation__: The degree to which this transaction is isolated from the work of other
204
- transactions. For example, can this transaction see uncommitted writes from other
205
- transactions?
206
202
* __Propagation__: Typically, all code executed within a transaction scope will run in
207
203
that transaction. However, you have the option of specifying the behavior in the event
208
204
that a transactional method is executed when a transaction context already exists. For
209
205
example, code can continue running in the existing transaction (the common case); or
210
206
the existing transaction can be suspended and a new transaction created. __Spring
211
207
offers all of the transaction propagation options familiar from EJB CMT__. To read
212
208
about the semantics of transaction propagation in Spring, see <<tx-propagation>>.
209
+ * __Isolation__: The degree to which this transaction is isolated from the work of other
210
+ transactions. For example, can this transaction see uncommitted writes from other
211
+ transactions?
213
212
* __Timeout__: How long this transaction runs before timing out and being rolled back
214
213
automatically by the underlying transaction infrastructure.
215
214
* __Read-only status__: A read-only transaction can be used when your code reads but
@@ -837,7 +836,7 @@ unhandled `InstrumentNotFoundException`.
837
836
</tx:advice>
838
837
----
839
838
840
- When the Spring Framework's transaction infrastructure catches an exception and is
839
+ When the Spring Framework's transaction infrastructure catches an exception and it
841
840
consults configured rollback rules to determine whether to mark the transaction for
842
841
rollback, the __strongest__ matching rule wins. So in the case of the following
843
842
configuration, any exception other than an `InstrumentNotFoundException` results in a
@@ -1028,17 +1027,17 @@ that are nested within `<tx:advice/>` and `<tx:attributes/>` tags are summarized
1028
1027
| `isolation`
1029
1028
| No
1030
1029
| DEFAULT
1031
- | Transaction isolation level.
1030
+ | Transaction isolation level. Only applicable to propagation REQUIRED or REQUIRES_NEW.
1032
1031
1033
1032
| `timeout`
1034
1033
| No
1035
1034
| -1
1036
- | Transaction timeout value (in seconds).
1035
+ | Transaction timeout ( seconds). Only applicable to propagation REQUIRED or REQUIRES_NEW .
1037
1036
1038
1037
| `read-only`
1039
1038
| No
1040
1039
| false
1041
- | Is this transaction read-only?
1040
+ | Read/write vs. read-only transaction. Only applicable to REQUIRED or REQUIRES_NEW.
1042
1041
1043
1042
| `rollback-for`
1044
1043
| No
@@ -1162,7 +1161,6 @@ transactional behavior.
1162
1161
1163
1162
[TIP]
1164
1163
====
1165
-
1166
1164
Spring recommends that you only annotate concrete classes (and methods of concrete
1167
1165
classes) with the `@Transactional` annotation, as opposed to annotating interfaces. You
1168
1166
certainly can place the `@Transactional` annotation on an interface (or an interface
@@ -1308,23 +1306,23 @@ annotation are summarized in the following table:
1308
1306
1309
1307
| <<tx-multiple-tx-mgrs-with-attransactional,value>>
1310
1308
| String
1311
- | Optional qualifier specifying the transaction manager to be used.
1309
+ | Optional qualifier specifying the transaction manager to be used.
1312
1310
1313
1311
| <<tx-propagation,propagation>>
1314
1312
| enum: `Propagation`
1315
1313
| Optional propagation setting.
1316
1314
1317
1315
| `isolation`
1318
1316
| enum: `Isolation`
1319
- | Optional isolation level.
1320
-
1321
- | `readOnly`
1322
- | boolean
1323
- | Read/write vs. read-only transaction
1317
+ | Optional isolation level. Only applicable to propagation REQUIRED or REQUIRES_NEW.
1324
1318
1325
1319
| `timeout`
1326
1320
| int (in seconds granularity)
1327
- | Transaction timeout.
1321
+ | Optional transaction timeout. Only applicable to propagation REQUIRED or REQUIRES_NEW.
1322
+
1323
+ | `readOnly`
1324
+ | boolean
1325
+ | Read/write vs. read-only transaction. Only applicable to REQUIRED or REQUIRES_NEW.
1328
1326
1329
1327
| `rollbackFor`
1330
1328
| Array of `Class` objects, which must be derived from `Throwable.`
@@ -1461,8 +1459,8 @@ PROPAGATION_REQUIRED
1461
1459
When the propagation setting is `PROPAGATION_REQUIRED`, a __logical__ transaction scope
1462
1460
is created for each method upon which the setting is applied. Each such logical
1463
1461
transaction scope can determine rollback-only status individually, with an outer
1464
- transaction scope being logically independent from the inner transaction scope. Of
1465
- course, in case of standard `PROPAGATION_REQUIRED` behavior, all these scopes will be
1462
+ transaction scope being logically independent from the inner transaction scope.
1463
+ Of course, in case of standard `PROPAGATION_REQUIRED` behavior, all these scopes will be
1466
1464
mapped to the same physical transaction. So a rollback-only marker set in the inner
1467
1465
transaction scope does affect the outer transaction's chance to actually commit (as you
1468
1466
would expect it to).
@@ -1484,11 +1482,14 @@ image::images/tx_prop_requires_new.png[width=400]
1484
1482
1485
1483
PROPAGATION_REQUIRES_NEW
1486
1484
1487
- `PROPAGATION_REQUIRES_NEW`, in contrast to `PROPAGATION_REQUIRED`, uses a __completely__
1488
- independent transaction for each affected transaction scope. In that case, the
1489
- underlying physical transactions are different and hence can commit or roll back
1485
+ `PROPAGATION_REQUIRES_NEW`, in contrast to `PROPAGATION_REQUIRED`, always uses an
1486
+ __independent__ physical transaction for each affected transaction scope, never
1487
+ participating in an existing transaction for an outer scope. In such an arrangement,
1488
+ the underlying resource transactions are different and hence can commit or roll back
1490
1489
independently, with an outer transaction not affected by an inner transaction's rollback
1491
- status.
1490
+ status, and with an inner transaction's locks released immediately after its completion.
1491
+ Such an independent inner transaction may also declare its own isolation level, timeout
1492
+ and read-only settings, never inheriting an outer transaction's characteristics.
1492
1493
1493
1494
[[tx-propagation-nested]]
1494
1495
===== Nested
@@ -1585,10 +1586,10 @@ is controlled through the `Ordered` interface. For full details on advice orderi
1585
1586
<!-- this is the aspect -->
1586
1587
<bean id="profiler" class="x.y.SimpleProfiler">
1587
1588
<!-- execute before the transactional advice (hence the lower order number) -->
1588
- <property name="order" __value ="1"__ />
1589
+ <property name="order" value ="1"/>
1589
1590
</bean>
1590
1591
1591
- <tx:annotation-driven transaction-manager="txManager" __order ="200"__ />
1592
+ <tx:annotation-driven transaction-manager="txManager" order ="200"/>
1592
1593
1593
1594
<aop:config>
1594
1595
<!-- this advice will execute around the transactional advice -->
@@ -1641,14 +1642,14 @@ declarative approach.
1641
1642
<!-- the profiling advice -->
1642
1643
<bean id="profiler" class="x.y.SimpleProfiler">
1643
1644
<!-- execute before the transactional advice (hence the lower order number) -->
1644
- __ <property name="order" value="1__ "/>
1645
+ <property name="order" value="1 "/>
1645
1646
</bean>
1646
1647
1647
1648
<aop:config>
1648
1649
<aop:pointcut id="entryPointMethod" expression="execution(* x.y..*Service.*(..))"/>
1649
1650
<!-- will execute after the profiling advice (c.f. the order attribute) -->
1650
1651
1651
- <aop:advisor advice-ref="txAdvice" pointcut-ref="entryPointMethod" __order="2__ "/>
1652
+ <aop:advisor advice-ref="txAdvice" pointcut-ref="entryPointMethod" order="2 "/>
1652
1653
<!-- order value is higher than the profiling aspect -->
1653
1654
1654
1655
<aop:aspect id="profilingAspect" ref="profiler">
@@ -1721,7 +1722,7 @@ follows Java's rule that annotations on interfaces are __not inherited__.
1721
1722
====
1722
1723
1723
1724
The `@Transactional` annotation on a class specifies the default transaction semantics
1724
- for the execution of any method in the class.
1725
+ for the execution of any public method in the class.
1725
1726
1726
1727
The `@Transactional` annotation on a method within the class overrides the default
1727
1728
transaction semantics given by the class annotation (if present). Any method may be
@@ -1782,7 +1783,6 @@ a transaction. You then pass an instance of your custom `TransactionCallback` to
1782
1783
1783
1784
// use constructor-injection to supply the PlatformTransactionManager
1784
1785
public SimpleService(PlatformTransactionManager transactionManager) {
1785
- Assert.notNull(transactionManager, "The 'transactionManager' argument must not be null.");
1786
1786
this.transactionTemplate = new TransactionTemplate(transactionManager);
1787
1787
}
1788
1788
@@ -1849,7 +1849,6 @@ a specific `TransactionTemplate:`
1849
1849
private final TransactionTemplate transactionTemplate;
1850
1850
1851
1851
public SimpleService(PlatformTransactionManager transactionManager) {
1852
- Assert.notNull(transactionManager, "The 'transactionManager' argument must not be null.");
1853
1852
this.transactionTemplate = new TransactionTemplate(transactionManager);
1854
1853
1855
1854
// the transaction settings can be set here explicitly if so desired
@@ -1943,9 +1942,9 @@ Registering a regular event listener is done via the `@EventListener` annotation
1943
1942
to bind it to the transaction use `@TransactionalEventListener`. When you do so, the listener
1944
1943
will be bound to the commit phase of the transaction by default.
1945
1944
1946
- Let's take an example to illustrate this concept. Assume that a component publish an order
1945
+ Let's take an example to illustrate this concept. Assume that a component publishes an order
1947
1946
created event and we want to define a listener that should only handle that event once the
1948
- transaction in which it has been published as committed successfully:
1947
+ transaction in which it has been published has committed successfully:
1949
1948
1950
1949
[source,java,indent=0]
1951
1950
[subs="verbatim,quotes"]
@@ -1960,8 +1959,8 @@ transaction in which it has been published as committed successfully:
1960
1959
}
1961
1960
----
1962
1961
1963
- The `TransactionalEventListener` annotation exposes a `phase` attribute that allows to customize
1964
- to which phase of the transaction the listener should be bound to. The valid phases are `BEFORE_COMMIT`,
1962
+ The `TransactionalEventListener` annotation exposes a `phase` attribute that allows us to customize
1963
+ which phase of the transaction the listener should be bound to. The valid phases are `BEFORE_COMMIT`,
1965
1964
`AFTER_COMMIT` (default), `AFTER_ROLLBACK` and `AFTER_COMPLETION` that aggregates the transaction
1966
1965
completion (be it a commit or a rollback).
1967
1966
@@ -2997,10 +2996,10 @@ An `update()` convenience method supports the retrieval of primary keys generate
2997
2996
database. This support is part of the JDBC 3.0 standard; see Chapter 13.6 of the
2998
2997
specification for details. The method takes a `PreparedStatementCreator` as its first
2999
2998
argument, and this is the way the required insert statement is specified. The other
3000
- argument is a `KeyHolder`, which contains the generated key on successful return from
3001
- the update. There is not a standard single way to create an appropriate
3002
- `PreparedStatement` (which explains why the method signature is the way it is). The
3003
- following example works on Oracle but may not work on other platforms:
2999
+ argument is a `KeyHolder`, which contains the generated key on successful return from the
3000
+ update. There is not a standard single way to create an appropriate `PreparedStatement`
3001
+ (which explains why the method signature is the way it is). The following example works
3002
+ on Oracle but may not work on other platforms:
3004
3003
3005
3004
[source,java,indent=0]
3006
3005
[subs="verbatim,quotes"]
0 commit comments