日期:2014-05-20  浏览次数:20714 次

spring事务管理不会回滚
spring + hibernate , 弄了半天,还是不会回滚,哪位大虾帮帮忙
下面是配置事物的部分xml

<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
<aop:config>
<aop:pointcut id="transacionPointcut" expression="execution(* com.serviceImpl.UserServImpl.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="transacionPointcut"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="do*" rollback-for="Exception" propagation="REQUIRED"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<bean id="userDao" class="com.dao.impl.UserDaoImpl" autowire="byName"></bean>
<bean id="userServ" class="com.serviceImpl.UserServImpl"> 
<property name="userDao" ref="userDao">
</property>
</bean>
</beans>

这个是我要拦截的方法
public void doSomething() throws RuntimeException{
User user1 = new User();
user1.setName("测试1");
user1.setPassword("123");
userDao.insertUser(user1);

User user2 = new User();
user2.setName("测试2");
user2.setPassword("123");
userDao.insertUser(user2);

throw new RuntimeException("例外");

}
不知道为什么不会回滚

------解决方案--------------------
你用的是不是mySql啊? mysql默认安装好像不支持事务。。。。。个人愚见。