结构是SSH 我想问的是关于这个事务回滚的问题 ui和rs都没有回滚,请问是那里出现错误了
在action里处理
ui.setA(1);
ui = this.getUserService().saveUserInfo(ui);//保存 rs.setB(2);
rs = this.getDetailService().saveDetail(rs);//保存
throw new MyException();//强制抛出错误
在spring配置文件里应该是没错的 数据是Innodb
<bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="save*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="remove*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="update*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="del*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
在hibernateDAO
public UserInfo saveUserInfo(UserInfo userInfo) throws MyException {
try {
return this.getUserInfoDAO().saveUserInfo(userInfo);
}
catch (Exception ex) {
logger.error(ex);
throw new MyException(ex);
}
}
在action里处理
ui.setA(1);
ui = this.getUserService().saveUserInfo(ui);//保存 rs.setB(2);
rs = this.getDetailService().saveDetail(rs);//保存
throw new MyException();//强制抛出错误
在spring配置文件里应该是没错的 数据是Innodb
<bean id="txProxyTemplate" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="create*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="save*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="remove*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="update*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="del*">PROPAGATION_REQUIRED,-com.test.MyException</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
在hibernateDAO
public UserInfo saveUserInfo(UserInfo userInfo) throws MyException {
try {
return this.getUserInfoDAO().saveUserInfo(userInfo);
}
catch (Exception ex) {
logger.error(ex);
throw new MyException(ex);
}
}
你在action里抛一个异常,肯定不会回滚啊!!!
有抛就得有抓的,
谁catch勒,