问题描述
代码是这样的一个大事务里面嵌套两个子事务@Transactional(propagation=Propagation.REQUIRED)publicvoidAUDIT(SaleUserApplysaleUserApply){DataSourceContextHolder.setDataSourceType(DataSourceContextHolder.SALE_DATE_SOURCE);longexcId=saleUserApllyAUDIT1(saleUserApply);//--这个事务设置的是@Transactional(propagation=Propagation.NESTED)DataSourceContextHolder.setDataSourceType(DataSourceContextHolder.SYS_DATE_SOURCE);saleUserApllyAUDIT2(saleUserApply,excId);//--这个事务设置的是@Transactional(propagation=Propagation.NESTED)}
现在是只要操作数据库就会报Causedby:java.sql.SQLSyntaxErrorException:ORA-00942:表或视图不存在atoracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)atoracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)atoracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)atoracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)atoracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)atoracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)atoracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)atoracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)atoracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145)atoracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1267)atoracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)atoracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3550)atoracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)atcom.jolbox.bonecp.PreparedStatementHandle.execute(PreparedStatementHandle.java:163)atsun.reflect.GeneratedMethodAccessor76.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:45)atcom.sun.proxy.$Proxy76.execute(UnknownSource)atorg.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:39)atorg.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55)atorg.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41)atorg.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:238)atorg.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:112)atorg.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)atorg.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:78)atorg.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:72)atorg.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:38)atsun.reflect.GeneratedMethodAccessor116.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:338)
大神求解答,是因为spring嵌套事务不能管理多个数据源,还是什么原因?
解决方案
解决方案二:
不能,如果要用多个数据源的话,用分布式事务
解决方案三:
原来如此,你能给我一个分布式事务案例吗?我急用啊