You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2013/05/27 11:49:02 UTC

svn commit: r1486552 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java

Author: adrianc
Date: Mon May 27 09:49:02 2013
New Revision: 1486552

URL: http://svn.apache.org/r1486552
Log:
Entity engine optimization: Use SELECT * when the fields to select have not been specified.

There was some code to check for this, but it was testing a "fields to select" List that was never empty, so SELECT * was never used.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java?rev=1486552&r1=1486551&r2=1486552&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/datasource/GenericDAO.java Mon May 27 09:49:02 2013
@@ -707,8 +707,6 @@ public class GenericDAO {
                     Debug.logInfo("[" + modelEntity.getEntityName() + "]: auto-added field-sets: " + reasonSets, module);
                 }
             }
-        } else {
-            selectFields = modelEntity.getFieldsUnmodifiable();
         }
 
         StringBuilder sqlBuffer = new StringBuilder("SELECT ");
@@ -717,10 +715,23 @@ public class GenericDAO {
             sqlBuffer.append("DISTINCT ");
         }
 
-        if (selectFields.size() > 0) {
-            modelEntity.colNameString(selectFields, sqlBuffer, "", ", ", "", datasourceInfo.aliasViews);
+        if (modelEntity instanceof ModelViewEntity) {
+            // Views must have enumerated fields in SELECT.
+            if (selectFields.isEmpty()) {
+                modelEntity.colNameString(modelEntity.getFieldsUnmodifiable(), sqlBuffer, "", ", ", "", datasourceInfo.aliasViews);
+            } else {
+                modelEntity.colNameString(selectFields, sqlBuffer, "", ", ", "", datasourceInfo.aliasViews);
+            }
         } else {
-            sqlBuffer.append("*");
+            if (selectFields.isEmpty()) {
+                sqlBuffer.append("*");
+            } else {
+                modelEntity.colNameString(selectFields, sqlBuffer, "", ", ", "", datasourceInfo.aliasViews);
+            }
+        }
+        if (selectFields.isEmpty()) {
+            // The code that follows must have a non-empty list.
+            selectFields = modelEntity.getFieldsUnmodifiable();
         }
 
         // populate the info from entity-condition in the view-entity, if it is one and there is one