[logs] log error message if couldn't execute a single query
authorAsier Lostalé <asier.lostale@openbravo.com>
Thu, 12 Feb 2015 11:27:35 +0100
changeset 26006 d31a4c9419b0
parent 26005 782fe19378d5
child 26007 0b04430510b2
[logs] log error message if couldn't execute a single query
modules/org.openbravo.utility.cleanup.log/src/org/openbravo/utility/cleanup/log/CleanEntity.java
--- a/modules/org.openbravo.utility.cleanup.log/src/org/openbravo/utility/cleanup/log/CleanEntity.java	Thu Feb 12 10:56:59 2015 +0100
+++ b/modules/org.openbravo.utility.cleanup.log/src/org/openbravo/utility/cleanup/log/CleanEntity.java	Thu Feb 12 11:27:35 2015 +0100
@@ -89,7 +89,13 @@
     log.debug("  Query: {}", hql);
 
     Session s = OBDal.getInstance().getSession();
-    int affectedRows = s.createQuery(hql).executeUpdate();
+    int affectedRows = 0;
+    try {
+      affectedRows = s.createQuery(hql).executeUpdate();
+    } catch (Exception e) {
+      log.error("Error executing cleanup query \"{}\"", hql, e);
+      bgLogger.log("Error executing cleanup query \"" + hql + "\":  " + e.getMessage() + "\n");
+    }
     String logMsg = "Deleted " + affectedRows + " rows";
 
     log.debug(logMsg);