Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eclipselink 2.4.2 ScrollableCursor return REsult Set Close
Eclipselink 2.4.2 ScrollableCursor return REsult Set Close [message #1761210] Tue, 09 May 2017 00:08
Estevao Jordao is currently offline Estevao JordaoFriend
Messages: 3
Registered: December 2015
Junior Member
I beg for help here.
I already tried everything and could not make it work.

I'm calling a PROCEDURE, which returns a refcursor. My code executes perfectly, however the ScrollableCursor is with the result set closed and I can not find out why or how to do otherwise.

Please help me person. This is very difficult



My Error:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.2.v20130514-5956486): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Result set already closed



EntityManagerFactory createEntityManagerFactory = Persistence.createEntityManagerFactory("localFactPU");
    	
    	//EntityManager em = FJPAManager.getInstance().getEntityManagerContext("localFactPU").getEntityManager();
    	
    	EntityManager em = createEntityManagerFactory.createEntityManager();
    	em.getTransaction().begin();
    	
    	em.getTransaction().isActive();
    	System.out.println(em.isOpen());
    	
    	
        //em.getTransaction().begin();
    	
    	ReadAllQuery databaseQuery = new ReadAllQuery(DBAJobsOracleEntity.class);
    	databaseQuery.useCursoredStream();
    	StoredProcedureCall calles = new StoredProcedureCall();
    	calles.setProcedureName("FAC_JOB_INTEGRATION.TEST_ESTEVAO");
    	calles.useNamedCursorOutputAsResultSet("JOBS_PARAM");
    	databaseQuery.setCall(calles);

    	databaseQuery.useCursoredStream();
    	databaseQuery.useScrollableCursor(1000);
    	//session = ((JpaEntityManager) getEntityManager().getDelegate()).getActiveSession();
    	//session.executeQuery(databaseQuery);
    	
    	
    	//JpaQuery  queryess = (JpaQuery) ((JpaEntityManager)getEntityManager().getDelegate()).createQuery(databaseQuery);
    	JpaQuery  queryess = (JpaQuery) ((JpaEntityManager)em.getDelegate()).createQuery(databaseQuery);
    	queryess.setHint(QueryHints.CURSOR, true);
    	queryess.setHint(QueryHints.CURSOR_INITIAL_SIZE, 2);
    	queryess.setHint(QueryHints.CURSOR_PAGE_SIZE, 5);
    	queryess.setHint(QueryHints.RESULT_SET_CONCURRENCY, ResultSetConcurrency.ReadOnly);
    	
    	String resultSetType = ResultSetType.DEFAULT;
    	queryess.setHint(QueryHints.RESULT_SET_TYPE, resultSetType);
        ScrollableCursor scrollableCursor = (ScrollableCursor)queryess.getResultCursor();
        
        DatabaseSessionImpl databaseSession = ((JpaEntityManager)em.getDelegate()).getDatabaseSession();
        scrollableCursor.setSession(databaseSession);
                     
        scrollableCursor.next();
        scrollableCursor.close();
Previous Topic:How to use JPA-RS without J2EE environment?
Next Topic:Difference between Dynamic vs Static weaving in Weblogic 12c
Goto Forum:
  


Current Time: Tue Dec 12 18:11:34 GMT 2017

Powered by FUDForum. Page generated in 0.01543 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software