fixes BUG-43397:Applied new HQL Style
authorIñigo Lerga <inigo.lerga@openbravo.com>
Tue, 03 Mar 2020 12:30:08 +0100
changeset 37155 0c47875d6942
parent 37154 c65a5e95a092
child 37156 8ace6f1061cc
fixes BUG 43397:Applied new HQL Style
src/org/openbravo/event/OrderEventHandler.java
--- a/src/org/openbravo/event/OrderEventHandler.java	Tue Mar 03 11:18:01 2020 +0100
+++ b/src/org/openbravo/event/OrderEventHandler.java	Tue Mar 03 12:30:08 2020 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2013-2019 Openbravo SLU 
+ * All portions are Copyright (C) 2013-2020 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -26,7 +26,6 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
 import org.hibernate.criterion.Restrictions;
-import org.hibernate.query.Query;
 import org.openbravo.base.model.Entity;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.Property;
@@ -42,7 +41,6 @@
 import org.openbravo.model.common.businesspartner.BusinessPartner;
 import org.openbravo.model.common.enterprise.Warehouse;
 import org.openbravo.model.common.order.Order;
-import org.openbravo.model.common.order.OrderDiscount;
 import org.openbravo.model.common.order.OrderLine;
 
 class OrderEventHandler extends EntityPersistenceEventObserver {
@@ -199,13 +197,17 @@
   }
 
   private void removeDiscountInformationFromOrder(final OrderParameters orderParameters) {
-    StringBuilder deleteHql = new StringBuilder();
-    deleteHql.append(" delete from " + OrderDiscount.ENTITY_NAME);
-    deleteHql.append(" where " + OrderDiscount.PROPERTY_SALESORDER + ".id = :orderId");
-    @SuppressWarnings("rawtypes")
-    Query deleteQry = OBDal.getInstance().getSession().createQuery(deleteHql.toString());
-    deleteQry.setParameter("orderId", orderParameters.getOrderId());
-    deleteQry.executeUpdate();
+    //@formatter:off
+    final String deleteHql =
+                    " delete from OrderDiscount" +
+                    " where salesOrder.id = :orderId";
+    //@formatter:on
+
+    OBDal.getInstance()
+        .getSession()
+        .createQuery(deleteHql)
+        .setParameter("orderId", orderParameters.getOrderId())
+        .executeUpdate();
   }
 
   private class OrderParameters {