0 Replies Latest reply on May 5, 2011 8:44 AM by 839484

    JPA / Eclipselink CursoredStream Error

      Hi there!
      I have to do a database request on an Oracle XE database which returns about 1 million entities. As it does not make sense to load all of them to memory, I chose a Cursored Stream to do the work.
      My code:
                      /* count nbo entities */
                      ReadAllQuery query = new ReadAllQuery(Entity.class);
                      query.useCursoredStream(5, NBO_ENTITIES_TO_BE_READ_PER_CHUNK);
                      /* disable caching */
                      CursoredStream stream =
                              (CursoredStream) ((EntityManagerImpl) _entityManager).getSession()
                       * run through cursor
                      while (!stream.atEnd()) {
                          List<Entity> entities = null;
                          entities = stream.read(NBO_ENTITIES_TO_BE_READ_PER_CHUNK);
                          }catch(Exception e ){
                          doSomeWork( entities);
      The statement does fine with the first loads of data. However, while reading the last chunk of data, the following error happens:
      xception Description: An attempt to read beyond the end of stream occurred.
      Query: ReadAllQuery(referenceClass=Entity)
           at org.eclipse.persistence.exceptions.QueryException.readBeyondStream(QueryException.java:937)
           at org.eclipse.persistence.queries.CursoredStream.copy(CursoredStream.java:117)
           at org.eclipse.persistence.queries.CursoredStream.read(CursoredStream.java:327)
           at de.optware.dataloader.service.LieferantenstandortListService$1.run(LieferantenstandortListService.java:91)
           at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
           at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
           at java.util.concurrent.FutureTask.run(FutureTask.java:138)
           at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
           at java.lang.Thread.run(Thread.java:662)
      I am using eclipselink 1.1.2 and the ojdbc14 jdbc driver.

      Any ideas?

      Edited by: user12188472 on 05.05.2011 01:40

      Edited by: user12188472 on 05.05.2011 01:44