嵌套事務須要jdbc driver的支持!java
org.springframework.transaction.NestedTransactionNotSupportedException: Cannot create a nested transaction because savepoints are not supported by your JDBC driver at org.springframework.jdbc.datasource.JdbcTransactionObjectSupport.createSavepoint(JdbcTransactionObjectSupport.java:106) at org.springframework.transaction.support.AbstractTransactionStatus.createAndHoldSavepoint(AbstractTransactionStatus.java:144) at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:458) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:349) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:447) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:277) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
@Transactional默認RuntimeException 與 Error 類型回滾, 因此須要手動指定rollbackFor=Exception.class。spring
TransactionInterceptor extends TransactionAspectSupport implements MethodInterceptor, Serializablespa
TransactionAspectSupport implements BeanFactoryAware, InitializingBeancode
DefaultTransactionAttribute extends DefaultTransactionDefinition implements TransactionAttributeorm