Related to issue Related to issue 29766: Retail Operations Buffer: store all transactions in operations table before processing
authorMartin Taal <martin.taal@openbravo.com>
Fri, 05 Jun 2015 23:09:57 +0200
changeset 26863 329266db2ac8
parent 26862 aec312b262e2
child 26864 7419f65cdeb3
Related to issue Related to issue 29766: Retail Operations Buffer: store all transactions in operations table before processing
Close the scrollable result
src/org/openbravo/service/importprocess/ImportEntryManager.java
--- a/src/org/openbravo/service/importprocess/ImportEntryManager.java	Fri Jun 05 11:07:14 2015 +0200
+++ b/src/org/openbravo/service/importprocess/ImportEntryManager.java	Fri Jun 05 23:09:57 2015 +0200
@@ -513,23 +513,29 @@
 
                 final Query entriesQry = OBDal.getInstance().getSession()
                     .createQuery(importEntryQryStr);
+                entriesQry.setFirstResult(0);
+                entriesQry.setFetchSize(100);
                 entriesQry.setMaxResults(manager.importBatchSize);
 
                 final ScrollableResults entries = entriesQry.scroll(ScrollMode.FORWARD_ONLY);
-                while (entries.next()) {
-                  entryCount++;
-                  final Object[] values = (Object[]) entries.get();
-                  final ImportEntryInformation importEntryInformation = new ImportEntryInformation(
-                      importEntryProperties, values);
-                  try {
-                    manager.handleImportEntry(importEntryInformation);
-                  } catch (Throwable t) {
-                    // ImportEntryProcessors are custom implementations which can cause
-                    // errors, so always catch them to prevent other import entries
-                    // from not getting processed
-                    manager.setImportEntryError(importEntryInformation.getId(), t);
-                    OBDal.getInstance().flush();
+                try {
+                  while (entries.next()) {
+                    entryCount++;
+                    final Object[] values = (Object[]) entries.get();
+                    final ImportEntryInformation importEntryInformation = new ImportEntryInformation(
+                        importEntryProperties, values);
+                    try {
+                      manager.handleImportEntry(importEntryInformation);
+                    } catch (Throwable t) {
+                      // ImportEntryProcessors are custom implementations which can cause
+                      // errors, so always catch them to prevent other import entries
+                      // from not getting processed
+                      manager.setImportEntryError(importEntryInformation.getId(), t);
+                      OBDal.getInstance().flush();
+                    }
                   }
+                } finally {
+                  entries.close();
                 }
               }