3
votes

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)
5
post some code through which you are trying thisTheWhiteRabbit

5 Answers

3
votes

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.

1
votes

when using kodo set resultSetHoldability to 1 in Datasource custom property

1
votes

There are many ultimate causes for SQL Code -4470 in DB2. Here is a short list:

  1. Program error (like in this case), closing the cursor before it has been fully read.
  2. Bug in the installed JDBC driver: https://issues.jboss.org/browse/JBPAPP-2408
  3. Improper use of the driver due to incorrect documentation: http://www-01.ibm.com/support/docview.wss?uid=swg1IV45140
  4. 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
0
votes

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 Entities and 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/.

0
votes

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.