Java Reference
In-Depth Information
Because concurrent updates are handled by the database's serializable transaction
mechanism, neither statement locks rows or maintains a version number. Instead,
you must configure either the Spring TransactionInterceptor , which provides
transaction management for the transaction script, or the JDBC DataSource , which
creates JDBC connections.
Configuring the TransactionInterceptor
Here is an example of how to configure a TransactionInterceptor Spring bean to
use serializable transactions:
<bean id="DataSourceTransactionInterceptor"
class="org.springframework…TransactionInterceptor">
<property name="transactionManager">
<ref bean="DataSourceTransactionManager"/>
</property>
<property name="transactionAttributeSource">
<ref bean="MatchAllMethods"/>
</property>
</bean>
<bean id="MatchAllMethods"
class="org.springframework…MatchAlwaysTransactionAttributeSource">
<property name="transactionAttribute">
<value>PROPAGATION_REQUIRED, ISOLATION_SERIALIZABLE </value>
</property>
</bean>
The DataSourceTransactionInterceptor would be applied to the RestaurantNo-
tificationTransactionScripts class using a BeanNameProxyCreator Spring bean,
whose definition is not shown. These bean definitions specify that when any
method of the RestaurantNotificationTransactionScripts is invoked, the
TransactionInterceptor will execute that method in a serializable transaction.
Configuring a DataSource
Configuring a transaction interceptor to use a particular isolation level is a flexible
solution that enables different methods to use different isolation levels. The other
option is to set the isolation level for DataSource , which will cause all transactions
that use that DataSource to use that isolation level. The details of how to configure
a DataSource to use a particular isolation level are implementation specific. Here is
an example of how to configure a Database Connection Pool ( DBCP ) DataSource
Spring bean to use serializable transactions:
<beans>
<bean id="DataSource"
lazy-init="true"
 
 
Search WWH ::




Custom Search