事务回滚时无法抛出异常

时间:2018-03-01 02:32:00

标签: java spring hibernate jdbc

我有一个Rest API调用此方法

void Somemethod(){
EntityTransaction entityTransaction = null;
    EntityManager entityManager = null;
    try {
        entityManager = TXNMGMT.getEntityManager();
        entityTransaction = entityManager.getTransaction();
        entityTransaction.begin()

         // Does Something


        if (entityTransaction.isActive()) {
            entityTransaction.commit();
        }

} catch (Throwable throwable){
        throwable.printStackTrace();
        if (entityTransaction != null) {
            try {
                entityTransaction.rollback();
            } catch (Throwable throwable1){
                    throwable1.printStackTrace();
                    throw new UnkownBatchSaveException();
           }
        }
        throw new UnkownBatchSaveException();

    }
    finally {
        if(entityManager !=  null && entityManager.isOpen()) {
            entityManager.close();
        }

}

我知道这是UGLY

catch (Throwable throwable){
            throwable.printStackTrace();
            if (entityTransaction != null) {
                try {
                    entityTransaction.rollback();
                } catch (Throwable throwable1){
                        throwable1.printStackTrace();
                        throw new UnkownBatchSaveException();
               }
            }
            throw new UnkownBatchSaveException();

        }

然后我收到了这个错误

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
        at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:174)
        at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3403)
        at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3343)
        at sun.reflect.GeneratedMethodAccessor664.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347)
        at com.sun.proxy.$Proxy108.find(Unknown Source)
        at com.loylty.dataengine.repositories.impl.CustomerRepositoryImpl.findByUniqueCustomerId(CustomerRepositoryImpl.java:29)
        at com.loylty.dataengine.repositories.impl.CustomerRepositoryImpl$$FastClassBySpringCGLIB$$5332986c.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
        at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
        at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
        at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
        at com.loylty.dataengine.repositories.impl.CustomerRepositoryImpl$$EnhancerBySpringCGLIB$$403975c.findByUniqueCustomerId(<generated>)
        at com.loylty.dataengine.services.impl.CustomerServiceImpl.getCustomerByUniqueCustomerId(CustomerServiceImpl.java:228)
        at com.loylty.dataengine.services.impl.CustomerServiceImpl.save(CustomerServiceImpl.java:81)
        at com.loylty.rest.controller.CustomerController.BulkAddCustomersV3(CustomerController.java:184)
        at sun.reflect.GeneratedMethodAccessor691.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at com.loylty.rest.configuration.HttpLoggingFilter.doFilter(HttpLoggingFilter.java:54)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at com.loylty.rest.configuration.MdcRequestFilter.doFilter(MdcRequestFilter.java:26)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at com.loylty.rest.configuration.HttpLoggingFilter.doFilter(HttpLoggingFilter.java:54)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
        at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.getResultSet(AbstractLoadPlanBasedLoader.java:434)
        at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeQueryStatement(AbstractLoadPlanBasedLoader.java:186)
        at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121)
        at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86)
        at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.load(AbstractLoadPlanBasedEntityLoader.java:167)
        at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4019)
        at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:508)
        at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:478)
        at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:219)
        at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:278)
        at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)
        at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)
        at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1222)
        at org.hibernate.internal.SessionImpl.access$1900(SessionImpl.java:204)
        at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2776)
        at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2750)
        at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3379)
        ... 80 more
Caused by: java.sql.SQLException: Unexpected exception encountered during query.
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:569)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:512)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:480)
        at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2042)
        at com.mysql.cj.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1826)
        at com.mysql.cj.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:353)
        at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
        ... 97 more
Caused by: java.io.EOFException: Can not read response from server. Expected to read 1,419 bytes, read 233 bytes before connection was unexpectedly lost.
        at com.mysql.cj.core.io.FullReadInputStream.readFully(FullReadInputStream.java:61)
        at com.mysql.cj.mysqla.io.SimplePacketReader.readPayload(SimplePacketReader.java:104)
        at com.mysql.cj.mysqla.io.TimeTrackingPacketReader.readPayload(TimeTrackingPacketReader.java:53)
        at com.mysql.cj.mysqla.io.MultiPacketReader.readPayload(MultiPacketReader.java:57)
        at com.mysql.cj.mysqla.io.ResultsetRowReader.read(ResultsetRowReader.java:71)
        at com.mysql.cj.mysqla.io.ResultsetRowReader.read(ResultsetRowReader.java:38)
        at com.mysql.cj.mysqla.io.MysqlaProtocol.read(MysqlaProtocol.java:1605)
        at com.mysql.cj.mysqla.io.TextResultsetReader.read(TextResultsetReader.java:82)
        at com.mysql.cj.mysqla.io.TextResultsetReader.read(TextResultsetReader.java:43)
        at com.mysql.cj.mysqla.io.MysqlaProtocol.read(MysqlaProtocol.java:1617)
        at com.mysql.cj.mysqla.io.MysqlaProtocol.readAllResults(MysqlaProtocol.java:1663)
        at com.mysql.cj.mysqla.io.MysqlaProtocol.sqlQueryDirect(MysqlaProtocol.java:953)
        at com.mysql.cj.mysqla.MysqlaSession.sqlQueryDirect(MysqlaSession.java:431)
        at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2006)
        ... 101 more
2018-03-01 06:40:25,573 DEBUG [b75dc1da-9336-413e-b9be-d3fcbcfea511] Resolving exception from handler [public com.loylty.dataengine.model.ApiResponse<java.lang.Void> co
m.loylty.rest.controller.CustomerController.BulkAddCustomersV3(java.util.List<com.loylty.dataengine.entities.CustomerLedger>,java.lang.String)]: org.hibernate.Transacti
onException: Unable to rollback against JDBC Connection
2018-03-01 06:40:25,573 DEBUG [b75dc1da-9336-413e-b9be-d3fcbcfea511] Resolving exception from handler [public com.loylty.dataengine.model.ApiResponse<java.lang.Void> co
m.loylty.rest.controller.CustomerController.BulkAddCustomersV3(java.util.List<com.loylty.dataengine.entities.CustomerLedger>,java.lang.String)]: org.hibernate.Transacti
onException: Unable to rollback against JDBC Connection
2018-03-01 06:40:25,754 DEBUG [b75dc1da-9336-413e-b9be-d3fcbcfea511] Resolving exception from handler [public com.loylty.dataengine.model.ApiResponse<java.lang.Void> co
m.loylty.rest.controller.CustomerController.BulkAddCustomersV3(java.util.List<com.loylty.dataengine.entities.CustomerLedger>,java.lang.String)]: org.hibernate.Transacti
onException: Unable to rollback against JDBC Connection
2018-03-01 06:40:25,921 DEBUG [b75dc1da-9336-413e-b9be-d3fcbcfea511] Could not complete request
org.hibernate.TransactionException: Unable to rollback against JDBC Connection
        at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.rollback(AbstractLogicalConnectionImplementor.java:119)
        at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.rollback(JdbcResourceLocalT
ransactionCoordinatorImpl.java:239)
        at org.hibernate.engine.transaction.internal.TransactionImpl.rollback(TransactionImpl.java:100)
        at com.loylty.dataengine.services.impl.CustomerServiceImpl.save(CustomerServiceImpl.java:123)
        at com.loylty.rest.controller.CustomerController.BulkAddCustomersV3(CustomerController.java:184)
        at sun.reflect.GeneratedMethodAccessor691.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at com.loylty.rest.configuration.HttpLoggingFilter.doFilter(HttpLoggingFilter.java:54)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at com.loylty.rest.configuration.MdcRequestFilter.doFilter(MdcRequestFilter.java:26)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at com.loylty.rest.configuration.HttpLoggingFilter.doFilter(HttpLoggingFilter.java:54)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:89)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:784)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:802)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1410)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown.
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:550)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:512)
        at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:480)
        at com.mysql.cj.jdbc.ConnectionImpl.rollback(ConnectionImpl.java:3586)
        at com.mchange.v2.c3p0.impl.NewProxyConnection.rollback(NewProxyConnection.java:1033)
        at org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor.rollback(AbstractLogicalConnectionImplementor.java:114)
        ... 66 common frames omitted
2018-03-01 06:40:25,929 ERROR [b75dc1da-9336-413e-b9be-d3fcbcfea511] Request processing failed; nested exception is org.hibernate.TransactionException: Unable to rollback against JDBC Connection
2018-03-01 06:40:25,930 ERROR  null
2018-03-01 06:40:25,930 DEBUG  Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@23969f80
2018-03-01 06:40:31,240 DEBUG  Bound request context to thread: org.apache.catalina.connector.RequestFacade@23969f80

但在这种情况下,我永远不会得到UnkownBatchSaveException();并且调用API只能获得200&amp;它假定申请成功了

为什么我在回滚时无法抛出UnkownBatchSaveException();

0 个答案:

没有答案