Java Reference
In-Depth Information
more elaborate tests that run against the database—yet another reason to use
SQL
only if it is absolutely necessary.
Let's now look at how to deploy the transaction scripts.
9.5 Configuring the transaction scripts using Spring
We have almost finished implementing the business logic for this use case. The
final step in the process of implementing transaction scripts is to write the Spring
bean definitions that wire together the various classes and apply the
AOP
intercep-
tors that manage transactions and
JDBC
connections.
9.5.1
How Spring manages JDBC connections and transactions
Spring has an
AOP
-based mechanism for managing JDBC connections and trans-
actions. It uses the
TransactionInterceptor
class, which you saw earlier in
chapter 7, with a
DataSourceTransactionManager
, which is a Spring
Platform-
TransactionManager
that manages transactions using
JDBC
. Figure 9.8 shows these
classes and interfaces.
Spring
<<interface>>
Platform
Transaction
Manager
Transaction
Interceptor
DataSource
Transaction
Manager
JDBC
<<interface>>
Connection
<<interface>>
DataSource
setAutoCommit()
commit()
rollback()
close()
...
Connection getConnection()
Figure 9.8
Spring classes for managing JDBC connections and transactions
Search WWH ::
Custom Search