details:   https://code.openbravo.com/erp/devel/pi/rev/0906b858ed6e
changeset: 35322:0906b858ed6e
user:      David Miguelez <david.miguelez <at> openbravo.com>
date:      Thu Nov 22 17:36:26 2018 +0100
summary:   Fixes Issue 0039163:QueryTimeoutException is no longer
thrown in Oracle after Hibernate 5.3 upgrade

** Use split to show proper message in catch block
for GenericJDBCException.
** Catch block for QueryTimeOutException not required any longer.

diffstat:

 src/org/openbravo/materialmgmt/InventoryCountProcess.java             |  24 
++-------
 src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java |  12 
+----
 src/org/openbravo/materialmgmt/VariantChDescUpdateProcess.java        |  12 
+----
 3 files changed, 7 insertions(+), 41 deletions(-)

diffs (118 lines):

diff -r 88d362c8aba0 -r 0906b858ed6e 
src/org/openbravo/materialmgmt/InventoryCountProcess.java
--- a/src/org/openbravo/materialmgmt/InventoryCountProcess.java Wed Jan 16 
11:06:26 2019 +0100
+++ b/src/org/openbravo/materialmgmt/InventoryCountProcess.java Thu Nov 22 
17:36:26 2018 +0100
@@ -32,7 +32,6 @@
 import org.apache.commons.lang.time.DateUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.hibernate.QueryTimeoutException;
 import org.hibernate.Session;
 import org.hibernate.exception.GenericJDBCException;
 import org.hibernate.query.Query;
@@ -107,26 +106,12 @@
 
       bundle.setResult(msg);
 
-      // Postgres wraps the exception into a GenericJDBCException
     } catch (GenericJDBCException ge) {
       log4j.error("Exception processing physical inventory", ge);
       msg.setType("Error");
       msg.setTitle(OBMessageUtils.messageBD(bundle.getConnection(), "Error", 
bundle.getContext()
           .getLanguage()));
-      msg.setMessage(ge.getSQLException().getMessage());
-      bundle.setResult(msg);
-      OBDal.getInstance().rollbackAndClose();
-      final String recordID = (String) 
bundle.getParams().get("M_Inventory_ID");
-      final InventoryCount inventory = 
OBDal.getInstance().get(InventoryCount.class, recordID);
-      inventory.setProcessNow(false);
-      OBDal.getInstance().save(inventory);
-      // Oracle wraps the exception into a QueryTimeoutException
-    } catch (QueryTimeoutException qte) {
-      log4j.error("Exception processing physical inventory", qte);
-      msg.setType("Error");
-      msg.setTitle(OBMessageUtils.messageBD(bundle.getConnection(), "Error", 
bundle.getContext()
-          .getLanguage()));
-      msg.setMessage(qte.getSQLException().getMessage().split("\n")[0]);
+      msg.setMessage(ge.getSQLException().getMessage().split("\n")[0]);
       bundle.setResult(msg);
       OBDal.getInstance().rollbackAndClose();
       final String recordID = (String) 
bundle.getParams().get("M_Inventory_ID");
@@ -296,8 +281,8 @@
   private void checkMandatoryAttributesWithoutVavlue(InventoryCount inventory) 
{
     InventoryCountLine inventoryLine = 
getLineWithMandatoryAttributeWithoutValue(inventory);
     if (inventoryLine != null) {
-      throw new OBException(OBMessageUtils.parseTranslation("@Inline@ " + 
(inventoryLine).getLineNo()
-          + " @productWithoutAttributeSet@"));
+      throw new OBException(OBMessageUtils.parseTranslation("@Inline@ "
+          + (inventoryLine).getLineNo() + " @productWithoutAttributeSet@"));
     }
   }
 
@@ -386,7 +371,8 @@
     OrganizationStructureProvider osp = 
OBContext.getOBContext().getOrganizationStructureProvider(
         inventory.getClient().getId());
     Organization inventoryLegalOrBusinessUnitOrg = 
osp.getLegalEntityOrBusinessUnit(org);
-    List<InventoryCountLine> inventoryLineList = 
getLinesWithDifferentOrganizationThanHeader(inventory, org);
+    List<InventoryCountLine> inventoryLineList = 
getLinesWithDifferentOrganizationThanHeader(
+        inventory, org);
     if (!inventoryLineList.isEmpty()) {
       for (InventoryCountLine inventoryLine : inventoryLineList) {
         if (!inventoryLegalOrBusinessUnitOrg.getId().equals(
diff -r 88d362c8aba0 -r 0906b858ed6e 
src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java
--- a/src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java     
Wed Jan 16 11:06:26 2019 +0100
+++ b/src/org/openbravo/materialmgmt/VariantAutomaticGenerationProcess.java     
Thu Nov 22 17:36:26 2018 +0100
@@ -29,7 +29,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.hibernate.QueryTimeoutException;
 import org.hibernate.criterion.Restrictions;
 import org.hibernate.exception.GenericJDBCException;
 import org.openbravo.advpaymentmngt.utility.FIN_Utility;
@@ -241,16 +240,7 @@
       msg.setType("Error");
       msg.setTitle(OBMessageUtils.messageBD(bundle.getConnection(), "Error", 
bundle.getContext()
           .getLanguage()));
-      msg.setMessage(ge.getSQLException().getMessage());
-      bundle.setResult(msg);
-      OBDal.getInstance().rollbackAndClose();
-      // Oracle wraps the exception into a QueryTimeoutException
-    } catch (QueryTimeoutException qte) {
-      log4j.error("Exception processing variant generation", qte);
-      msg.setType("Error");
-      msg.setTitle(OBMessageUtils.messageBD(bundle.getConnection(), "Error", 
bundle.getContext()
-          .getLanguage()));
-      msg.setMessage(qte.getSQLException().getMessage().split("\n")[0]);
+      msg.setMessage(ge.getSQLException().getMessage().split("\n")[0]);
       bundle.setResult(msg);
       OBDal.getInstance().rollbackAndClose();
     } catch (final Exception e) {
diff -r 88d362c8aba0 -r 0906b858ed6e 
src/org/openbravo/materialmgmt/VariantChDescUpdateProcess.java
--- a/src/org/openbravo/materialmgmt/VariantChDescUpdateProcess.java    Wed Jan 
16 11:06:26 2019 +0100
+++ b/src/org/openbravo/materialmgmt/VariantChDescUpdateProcess.java    Thu Nov 
22 17:36:26 2018 +0100
@@ -21,7 +21,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.hibernate.QueryTimeoutException;
 import org.hibernate.ScrollMode;
 import org.hibernate.ScrollableResults;
 import org.hibernate.exception.GenericJDBCException;
@@ -62,16 +61,7 @@
       msg.setType("Error");
       msg.setTitle(OBMessageUtils.messageBD(bundle.getConnection(), "Error", 
bundle.getContext()
           .getLanguage()));
-      msg.setMessage(ge.getSQLException().getMessage());
-      bundle.setResult(msg);
-      OBDal.getInstance().rollbackAndClose();
-      // Oracle wraps the exception into a QueryTimeoutException
-    } catch (QueryTimeoutException qte) {
-      log4j.error("Exception processing variant generation", qte);
-      msg.setType("Error");
-      msg.setTitle(OBMessageUtils.messageBD(bundle.getConnection(), "Error", 
bundle.getContext()
-          .getLanguage()));
-      msg.setMessage(qte.getSQLException().getMessage().split("\n")[0]);
+      msg.setMessage(ge.getSQLException().getMessage().split("\n")[0]);
       bundle.setResult(msg);
       OBDal.getInstance().rollbackAndClose();
     } catch (final Exception e) {


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to