请教下spring的事务管理问题

刚使用SPRING,在程序中使用了事务管理。
下面是在SimpleService里调用的addError()方法,在2出产生的异常并没用回滚1处的数据,希望各位指导下哪里出了问题,谢谢
public void addError() throws Exception {
SimpleDao dao = new SimpleDao(getDataSource());
dao.addRightInfo();//1---插入正确记录
dao.addErrorInfo();//2---插入错误记录


PS:在dao中使用的是NamedParameterJdbcTemplate类操作数据,是否数据已经提交无法再回滚了?

下面是主要的配置
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean name="transactionInterceptorBeanGroup"
class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>

<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED</prop>
<prop key="modify*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>simpleService</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptorBeanGroup</value>
</list>
</property>
</bean>
<bean id="simpleService" class="test.SimpleService">
<property name="dataSource" ref="dataSource" />
</bean>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值