Spring中Transactional不添加rollbackFor等属性时的事务回滚有关问题
Spring中Transactional不添加rollbackFor等属性时的事务回滚问题
昨天同事说spring的Transactional必须添加rollbackFor = Exception.class,否则事务不会回滚。但我原来试过,抛出RuntimeException时是会回滚的。于是查看Spring的Transactional的API文档,发现下面这段:
If no rules are relevant to the exception, it will be treated like DefaultTransactionAttribute
(rolling back on runtime exceptions).
后面又试了下发现,如果不添加rollbackFor等属性,Spring碰到Unchecked Exceptions都会回滚,不仅是RuntimeException,也包括Error。
转:http://blog.****.net/snowclash/article/details/5819821