fixed issue 15555: In Oracle, Enterprise Module Management window shows an error message on open
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 31 Dec 2010 09:22:25 +0100
changeset 9506 cfca6a9741cb
parent 9505 84bccb79d739
child 9507 b60bcce81c3a
fixed issue 15555: In Oracle, Enterprise Module Management window shows an error message on open

Applied workaround described in issue #15556: use OBQuery instead of OBCriteria.
src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree.java
--- a/src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree.java	Thu Dec 30 19:27:09 2010 +0100
+++ b/src/org/openbravo/erpCommon/modules/ModuleReferenceDataOrgTree.java	Fri Dec 31 09:22:25 2010 +0100
@@ -28,20 +28,15 @@
 import javax.servlet.ServletException;
 
 import org.apache.log4j.Logger;
-import org.hibernate.criterion.Expression;
 import org.openbravo.base.HttpBaseServlet;
 import org.openbravo.dal.core.OBContext;
-import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBQuery;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.erpCommon.utility.FieldProviderFactory;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.model.ad.module.ADOrgModule;
-import org.openbravo.model.ad.module.Module;
-import org.openbravo.model.ad.system.Client;
 import org.openbravo.model.ad.utility.DataSet;
-import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.xmlEngine.XmlDocument;
 
 /**
@@ -167,16 +162,18 @@
       if (checksum.equals("")) {
         continue;
       }
-      OBCriteria<ADOrgModule> adOrgModCriteria = OBDal.getInstance().createCriteria(
-          ADOrgModule.class);
-      adOrgModCriteria.add(Expression.eq(ADOrgModule.PROPERTY_MODULE, OBDal.getInstance().get(
-          Module.class, moduleId)));
-      adOrgModCriteria.add(Expression.eq(ADOrgModule.PROPERTY_CLIENT, OBDal.getInstance().get(
-          Client.class, strClient)));
-      adOrgModCriteria.add(Expression.eq(ADOrgModule.PROPERTY_ORGANIZATION, OBDal.getInstance()
-          .get(Organization.class, strOrg)));
-      adOrgModCriteria.add(Expression.eq(ADOrgModule.PROPERTY_CHECKSUM, checksum));
-      if (adOrgModCriteria.list().size() > 0) {
+
+      // OBCriteria cannot be used here because it is not able to filer CLOB in Oracle: using
+      // OBQuery instead. See issue #15556
+      String whereClause = "as m where m.module.id = :module and m.client.id=:client and m.organization.id=:org and to_char(m.checksum)=:checksum";
+      OBQuery<ADOrgModule> cOrgModule = OBDal.getInstance().createQuery(ADOrgModule.class,
+          whereClause);
+      cOrgModule.setNamedParameter("module", moduleId);
+      cOrgModule.setNamedParameter("client", strClient);
+      cOrgModule.setNamedParameter("org", strOrg);
+      cOrgModule.setNamedParameter("checksum", checksum);
+
+      if (cOrgModule.count() > 0) {
         dataList.remove(data[i]);
         log4j
             .debug("Module removed because datasets didn't change: " + data[i].getField("node_id"));