• javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: ResultSet is from UPDATE. No Data.


    Java jpa调用存储过程,抛出异常如下:

    javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: ResultSet is from UPDATE. No Data.
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1361)
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1289)
        at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:313)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:310)
        at com.sun.proxy.$Proxy65.getSingleResult(Unknown Source)
        at com.hxxr.operation.service.ProcedureServiceImpl.providerImageStatistics(ProcedureServiceImpl.java:51)
        at com.hxxr.analysis.gbm.job.service.ProcedureJobService$1.executeProcedure(ProcedureJobService.java:49)
        at com.hxxr.analysis.gbm.job.service.ProcedureJobService$1.run(ProcedureJobService.java:26)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
    Caused by: org.hibernate.exception.GenericJDBCException: ResultSet is from UPDATE. No Data.
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:52)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:108)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
        at com.sun.proxy.$Proxy68.next(Unknown Source)
        at org.hibernate.loader.Loader.doQuery(Loader.java:852)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
        at org.hibernate.loader.Loader.doList(Loader.java:2463)
        at org.hibernate.loader.Loader.doList(Loader.java:2449)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2279)
        at org.hibernate.loader.Loader.list(Loader.java:2274)
        at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:331)
        at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1585)
        at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:224)
        at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:156)
        at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:280)
        ... 14 more
    Caused by: java.sql.SQLException: ResultSet is from UPDATE. No Data.
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:997)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:983)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:928)
        at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:6995)
        at sun.reflect.GeneratedMethodAccessor32.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104)
        ... 27 more

     解决方式:

    根据存储过程执行的是查询、保存或者修改调用不同的方式即可。

    例如执行update修改命令,如下:

    Query query = entityManager.createNativeQuery("{call test()}");  
    query.executeUpdate(); 

    存储过程如下:

    BEGIN
      UPDATE test SET name = 'blog.yoodb.com' where id='12345678';
    END
  • 相关阅读:
    VS远程调试项目,利用msvsmon
    web deploy发布网站各种问题
    IOS中UITabBar、UIDatePicker、Picker View控件练习(二)
    IOS中多视图应用视图切换
    IOS中多视图应用设置首界面
    Asp.net中Application Session Cookie ViewState Cache Hidden
    UI控件(scrollView、tableView)的基本使用
    UI错误集
    UI小项目之拳皇动画的实现(抽取加载图片和播放音乐的方法)
    UI控件(Label、ImageView、Button)的基本使用
  • 原文地址:https://www.cnblogs.com/MrYoodb/p/4286016.html
Copyright © 2020-2023  润新知