Topic
2 replies Latest Post - ‏2012-03-28T14:38:28Z by bnorwood
bnorwood
bnorwood
9 Posts
ACCEPTED ANSWER

Pinned topic Result Set is closed error on JPA read

‏2012-03-28T14:02:21Z |
I'm using the IBM implentation of Open JPA on WebSphere 7 and I'm having an issue when I'm trying to reference an object that is @ManyToOne and keep getting the following error from DB2:

com.ibm.db2.jcc.b.SqlException: jcct41012010898http://3.50.152 Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null

I'm pulling my hair out as to why this doesn't work and hope that somebody can help.

Here is a simplified view the database schemas:

Table - Report
___________________
record_id - integer - (primary key - generated by DB2)
agency - integer not null (foreign key to Dropdown table)

Table Dropdown
___________________
record_id - integer - (primary key - generated by DB2)
Here is the JPA entity for the Report which references the agency
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="AGENCY")
private Dropdown agency;
Here is the code where I'm running a named query to get the data and then just iterating over the result set to print out the report id and the agnency. Whenever report.getAgency() is called, I get the "result set is closed" error from DB2:

@SuppressWarnings("unchecked")
public List<Report> getOpenIncidentsForUser(String aceId) throws Exception
{
List<Report> results = null;
EntityManager em = getEntityManager();

try
{
Query query = em.createNamedQuery("getOpenIncidentsForUser");
query.setParameter(1, aceId);
results = (List<Report>) query.getResultList();

Iterator<Report> it = results.iterator();
while(it.hasNext())
{
Report report = it.next();
System.out.println("Report Agency: ");
}
}
catch (Exception e)
{
log.fatal("Fatal error getting incidents for user", e);
throw e;
}
finally
{
em.close();
}

return (List<Report>) results;
}

if I don't ever refer to the getAgency method, I can print out anything else about the report with no problems. It only seems to be with the reference to the 2nd table. Any ideas?
Updated on 2012-03-28T14:38:28Z at 2012-03-28T14:38:28Z by bnorwood
  • leealber
    leealber
    19 Posts
    ACCEPTED ANSWER

    Re: Result Set is closed error on JPA read

    ‏2012-03-28T14:12:07Z  in response to bnorwood
    Check the following links and look for "Troubleshoot issues with closed cursors." and see it helps to resolve your problem.

    http://publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Ftejb_jpatroubleshoot.html&resultof=%22jpa%22%20%22trouble%22%20%22troubl%22

    http://publib.boulder.ibm.com/infocenter/wasinfo/v8r0/index.jsp?topic=%2Fcom.ibm.websphere.base.doc%2Finfo%2Faes%2Fae%2Ftejb_jpatroubleshoot.html&resultof=%22jpa%22%20%22trouble%22%20%22troubl%22

    Albert Lee.
    • bnorwood
      bnorwood
      9 Posts
      ACCEPTED ANSWER

      Re: Result Set is closed error on JPA read

      ‏2012-03-28T14:38:28Z  in response to leealber
      Wow, Thanks a ton for that link. I had somehow never run across that in all the searching I did trying to solve this. The problem was resultSetHoldability needed to be set to 1 instead of 2 in the datasource.

      Thanks again.