The framework offers the rollback rules to specify which types of exception the transaction will rollback. The rollback rules can be specified in XML, as follows:
<tx:advise id="transactionAdvise" transaction-manager ="transactionManager"> <tx:attributes> <tx:method name="find*" read-only="true" rollback- for ="NoDataFoundException'> </tx:attributes> </tx:advise>
The configuration can even specify the following attributes:
- no-rollback-for: This is to specify the exception when we don't want the transaction to rollback
- propagation: This is to specify the propagation behavior of a transaction with REQUIRED as its default value
- isolation: This is to specify the isolation level
- timeout: This transacts the timeout value in seconds, with -1 as default
Nowadays, as we tend to use annotation-based transaction management more, without wasting time, let's move on to annotation-based transaction management.