spring的事务管理:默认事务传播级别的情况下,当a调用b,b失败了会对事务做一个回滚标志。如果在a中try-catch了,则会报”Transaction rolled back because it has been marked as rollback-only” !(待测试!)
f (!shouldCommitOnGlobalRollbackOnly() && defStatus.isGlobalRollbackOnly()) {
if (defStatus.isDebug()) {
logger.debug("Global transaction is marked as rollback-only but transactional code requested commit");
}
processRollback(defStatus);
// Throw UnexpectedRollbackException only at outermost transaction boundary
// or if explicitly asked to.
if (status.isNewTransaction() || isFailEarlyOnGlobalRollbackOnly()) {
throw new UnexpectedRollbackException(
"Transaction rolled back because it has been marked as rollback-only");
}
return;
}
参考:http://www.iteye.com/problems/76921
http://blog.csdn.net/reliveit/article/details/45012271