java 无效操作:结果集已关闭。ERRORCODE=-4470,SQLSTATE=null
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14375357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null
提问by saagaravk
I am retrieving the certain data from table using key. I am using hibernate query to retrieve the data.
我正在使用密钥从表中检索某些数据。我正在使用休眠查询来检索数据。
I am able to retrieve the data for particular key . But for some other keys i am getting error or exceptions. the exception i am getting is
我能够检索特定键的数据。但是对于其他一些键,我收到错误或异常。我得到的例外是
[1/17/13 14:07:41:819 IST] 0000004c LongType I **org.hibernate.type.NullableType nullSafeGet could not read column value from result set: BRAND1_23_2_; [jcc][t4][10120][10898][3.58.81] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null** [1/17/13 14:07:41:822 IST] 0000004c JDBCException W org.hibernate.util.JDBCExceptionReporter logExceptions SQL Error: -4470, SQLState: null [1/17/13 14:07:41:823 IST] 0000004c JDBCException E org.hibernate.util.JDBCExceptionReporter logExceptions [jcc][t4][10120][10898][3.58.81] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null [1/17/13 14:07:41:826 IST] 0000004c DefaultLoadEv I org.hibernate.event.def.DefaultLoadEventListener onLoad Error performing load command org.hibernate.exception.GenericJDBCException: could not load an entity: [com.travelport.soa.gds.airline.brandedfares.entity.FareCollection#490] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
采纳答案by Marko Topolnik
You fetched an entity that has a one-to-many relationship represented in Java as a lazy-loaded Collection
and you are trying to iterate over that collection after you have already closed the Hibernate session within which you have fetched the object. You must either fetch the collection eagerly or widen the session boundaries to enclose your iteration code.
您获取了一个在 Java 中表示为延迟加载的具有一对多关系的实体,并且Collection
在您已经关闭获取该对象的 Hibernate 会话之后,您正尝试对该集合进行迭代。您必须急切地获取集合或扩大会话边界以包含您的迭代代码。
回答by user2247479
when using kodo set resultSetHoldability
to 1in Datasource custom property
在数据源自定义属性中使用设置resultSetHoldability
为1 的kodo 时
回答by pojo-guy
There are many ultimate causes for SQL Code -4470 in DB2. Here is a short list:
DB2 中的 SQL 代码 -4470 有许多最终原因。这是一个简短的列表:
- Program error (like in this case), closing the cursor before it has been fully read.
- Bug in the installed JDBC driver: https://issues.jboss.org/browse/JBPAPP-2408
- Improper use of the driver due to incorrect documentation: http://www-01.ibm.com/support/docview.wss?uid=swg1IV45140
- Bug in DB2 server: https://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.5.0/com.ibm.db2.luw.admin.trb.doc/doc/c0020806.html
- 程序错误(如本例),在游标被完全读取之前关闭游标。
- 已安装的 JDBC 驱动程序中的错误:https: //issues.jboss.org/browse/JBPAPP-2408
- 由于文档不正确导致驱动程序使用不当:http: //www-01.ibm.com/support/docview.wss?uid=swg1IV45140
- DB2 服务器中的错误:https: //www-01.ibm.com/support/knowledgecenter/SSEPGG_9.5.0/com.ibm.db2.luw.admin.trb.doc/doc/c0020806.html
回答by Joe Cotton
The reason that I got the same error was because I closed the db2 connection and then tried to read the result set. Please emphasis that the db2 must remain connected while reading the result set.
我得到同样错误的原因是因为我关闭了 db2 连接,然后尝试读取结果集。请强调 db2 在读取结果集时必须保持连接。
回答by Jacek Laskowski
If lazy/eager fetch strategy is an issue, you may want to use @OneToMany(fetch=FetchType.EAGER)
and perhaps read Hibernate One To Many Eager Not Pulling in all Data, How to Fetch @OneToMany and @ManyToMany Entitiesand A Short Primer On Fetching Strategies.
如果懒惰/急切的获取策略是一个问题,您可能需要使用@OneToMany(fetch=FetchType.EAGER)
并阅读Hibernate One To Many Eager Not Pulling in all Data,How to Fetch @OneToMany 和 @ManyToMany Entities和A Short Primer On Fetching Strategies。
I'd recommend posting a few snippets of how you get at the database and the affected records. You may want to use https://gist.github.com/.
我建议发布一些关于如何获取数据库和受影响记录的片段。您可能想使用https://gist.github.com/。