dao操作方法如下
public void update(String tagName ,Object obj) throws MwException
{
logger.debug("修改");
try{
this.getSqlMapClientTemplate().update(tagName,obj);
float f=1/0;
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//异常回滚操作
logger.debug("修改用户事务回滚了......");
}
}
三 tx:advice来配置事务,只不过有点小问题。只能对unchecked Exception进行回滚,对checked Exception 不能回滚
一下是配置,
< xml version="1.0" encoding="UTF-8" >
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
dao方法:
public void update(String tagName ,Object obj) throws MwException
{
logger.debug("修改");
try{
this.getSqlMapClientTemplate().update(tagName,obj);
float f=1/0;
} catch (Exception e) {