details:   https://code.openbravo.com/erp/devel/pi/rev/b96c7d42fc3e
changeset: 23013:b96c7d42fc3e
user:      Guillermo Gil <guillermo.gil <at> openbravo.com>
date:      Mon May 12 13:37:00 2014 +0200
summary:   Fixed issue 26505:Reference AD_Language does not show any results

Use left join instead an inner join if the property allows null values.

diffstat:

 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
 |  18 +++++++--
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r be00599a33b8 -r b96c7d42fc3e 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Mon May 12 12:26:29 2014 +0200
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Mon May 12 13:37:00 2014 +0200
@@ -231,10 +231,20 @@
         distinctPropName = Entity.COMPUTED_COLUMNS_PROXY_PROPERTY + 
DalUtil.DOT + distinctPropName;
       }
       whereClause += StringUtils.isEmpty(whereClause.trim()) ? "where" : "and";
-      whereClause += " exists (select 1 from " + subEntity.getName() + " "
-          + subEntityQueryBuilder.getJoinClause() + subentityWhere + "e."
-          + distinctPropertyPath.replace(DalUtil.FIELDSEPARATOR, DalUtil.DOT) 
+ " = " + mainAlias
-          + subEntityClientOrg + ") ";
+
+      // if the property allows null values, use a left join instead an inner 
join
+      if (subEntity.getProperty(distinctPropertyPath).allowNullValues()) {
+        whereClause += " exists (select 1 from " + subEntity.getName() + " "
+            + subEntityQueryBuilder.getJoinClause() + " left join "
+            + subEntityQueryBuilder.getMainAlias() + DalUtil.DOT + 
distinctPropertyPath + " as i "
+            + subentityWhere + " i = " + mainAlias + subEntityClientOrg + ") ";
+      } else {
+        whereClause += " exists (select 1 from " + subEntity.getName() + " "
+            + subEntityQueryBuilder.getJoinClause() + subentityWhere + "e."
+            + distinctPropertyPath.replace(DalUtil.FIELDSEPARATOR, 
DalUtil.DOT) + " = " + mainAlias
+            + subEntityClientOrg + ") ";
+      }
+
       typedParameters.addAll(subEntityQueryBuilder.typedParameters);
     }
 

------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos.
Get unparalleled scalability from the best Selenium testing platform available
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to