fixed 36601: unneeded flush with no entities on every fetch
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 04 Aug 2017 10:11:28 +0200
changeset 32535 b74ed74f842a
parent 32534 9b2210a5b692
child 32536 e6b6a636d1e4
fixed 36601: unneeded flush with no entities on every fetch

Fix includes:
- Do not flush on fetch just after clearing session as it is noop
- Being action an enum can be directly compared without need of getting its name
modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java
--- a/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Wed Jul 26 17:24:11 2017 -0400
+++ b/modules/org.openbravo.service.json/src/org/openbravo/service/json/DefaultJsonDataService.java	Fri Aug 04 10:11:28 2017 +0200
@@ -1130,14 +1130,13 @@
 
   protected String doPostAction(Map<String, String> parameters, String content,
       DataSourceAction action, String originalObject) {
-
-    // Clear session to prevent slow flush if a fetch is done
-    if (action.name().equals("FETCH")) {
+    if (action == DataSourceAction.FETCH) {
+      // Clear session to prevent slow flush
       OBDal.getInstance().getSession().clear();
+    } else {
+      OBDal.getInstance().flush();
     }
 
-    OBDal.getInstance().flush();
-
     try {
       // this gets the data before the insert, so that it can be used
       // for preprocessing, for example inserting an order