zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    谢惠民,恽自求,易法槐,钱定边编数学分析习题课讲义16.2.3练习题参考解答[来自陶哲轩小弟]
    高考题(可作为试讲资料)
    美国数学教父拒绝10亿美元 免费分享教学视频
    梁启超死亡真相:主刀医生错把健康的肾切除
    [家里蹲大学数学杂志]第418期南开大学2013年实变函数期末考试试题参考解答
    陆启铿同志去世
    [电视剧]养父的花样年华
    [电视剧]错爱一生
    [家里蹲大学数学杂志]第413期插值不等式
    Oracle的 EXEC SQL CONTEXT学习
  • 原文地址:https://www.cnblogs.com/MrYoodb/p/4286016.html
Copyright © 2011-2022 走看看