1. Spring MVC Configuration Exception thing rollback mechanism
<bean id= "DataSource" class= "Com.alibaba.druid.pool.DruidDataSource" init-method= "Init" destroy-method= "Close" >
...... Omitted
</bean>
<!--transaction Manager--
<bean id= "TransactionManager" class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<property name= "DataSource" ref= "DataSource"/>
</bean>
<!--transaction Control--
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "save*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "do*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "insert*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "add*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "update*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "edit*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "remove*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "delete*" propagation= "REQUIRED" rollback-for= "Exception"/>
<tx:method name= "get*" read-only= "true"/>
<tx:method name= "select*" read-only= "true"/>
<tx:method name= "find*" read-only= "true"/>
</tx:attributes>
</tx:advice>
2, in special cases, the use of manual things rollback, as follows
Note: Manual thing rollback is simple, but does not conform to spring's non-intrusive nature and makes the code highly coupled with the things of the spring framework.
Transactionaspectsupport.currenttransactionstatus (). Setrollbackonly ();
Java Manual things ROLLBACK TRANSACTION