This section covered some major configurations that you will deal with when processing
transactions on a day-to-day basis. For special cases, you may need to define the timeout, isolation level,
rollback (or not) for specific exceptions, and so on.
■ Note Spring's JpaTransactionManager doesn't support a custom isolation level. Instead, it will always use
the default isolation level for the underlying datastore. If you are using Hibernate as the JPA service provider, there
is a workaround when supporting a custom isolation level by extending the HibernateJpaDialect class (for
Using XML Configuration for Transaction Management
Another common approach of declarative transaction management is to use Spring's AOP support.
Before Spring version 2, we needed to use the TransactionProxyFactoryBean class to define transaction
requirements for Spring beans. However, ever since version 2, Spring provides a much simpler way by
introducing aop-namespace and using the common AOP configuration technique for defining transaction
requirements.
In this section, the example we will use is the same as the annotation one. We will just modify it to
the XML configuration style. Listing 13-18 shows the XML configuration file for transaction management
(tx-declarative-app-context.xml).
Listing 13-18. XML Configuration for Transaction Management
<?xml version="1.0" encoding="UTF-8"?>
<aop:config>
<aop:pointcut id="serviceOperation" expression=
Search WWH :