db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r524875 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql: SqlQueryStatement.java SqlSelectStatement.java SqlSubSelectStatement.java
Date Mon, 02 Apr 2007 18:20:17 GMT
Author: arminw
Date: Mon Apr  2 11:20:17 2007
New Revision: 524875

URL: http://svn.apache.org/viewvc?view=rev&rev=524875
Log:
fix problem with orderby-clause in sub-queries, if not supported don't add orderby-columns

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java?view=diff&rev=524875&r1=524874&r2=524875
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
Mon Apr  2 11:20:17 2007
@@ -510,7 +510,7 @@
      * @param columns the list of columns represented by Criteria.Field to ensure
      * @param existingColumns the list of column names (String) that are already appended
      */
-    protected void ensureColumns(List columns, List existingColumns)
+    protected void ensureColumnsGroupBy(List columns, List existingColumns)
     {
         if (columns == null || columns.isEmpty())
         {
@@ -538,7 +538,7 @@
      * @param buf the statement
      * @return List of existingColumns including ojb_col_x
      */
-    protected List ensureColumns(List columns, List existingColumns, StringBuffer buf)
+    protected List ensureColumnsOrderBy(List columns, List existingColumns, StringBuffer
buf)
     {
         if (columns == null || columns.isEmpty())
         {

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java?view=diff&rev=524875&r1=524874&r2=524875
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
Mon Apr  2 11:20:17 2007
@@ -336,10 +336,10 @@
             }
 
             groupByFields = query.getGroupBy();
-            ensureColumns(groupByFields, columnList);
+            ensureColumnsGroupBy(groupByFields, columnList);
             
             orderByFields = query.getOrderBy();
-            columnList = ensureColumns(orderByFields, columnList, stmt);
+            columnList = ensureColumnsOrderBy(orderByFields, columnList, stmt);
 /*
 arminw:
 TODO: this feature doesn't work, so remove this in future

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java?view=diff&rev=524875&r1=524874&r2=524875
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java
Mon Apr  2 11:20:17 2007
@@ -48,9 +48,25 @@
         }
         else
         {
-            getLogger().warn("SubSelect: Database doesn't support ORDER BY clause " +
-                    "in sub-select, execute sub-select without order by clause. Platform:
"
-                    + ClassUtils.getShortClassName(getPlatform().getClass()));
+            if(orderByFields != null && orderByFields.size() > 0)
+            {
+                getLogger().warn("SubSelect: Database doesn't support ORDER BY clause " +
+                        "in sub-select, execute sub-select without order by clause. Platform:
"
+                        + ClassUtils.getShortClassName(getPlatform().getClass()) + ", orderby="
+ orderByFields);
+            }
+
+        }
+    }
+
+    protected List ensureColumnsOrderBy(List columns, List existingColumns, StringBuffer
buf)
+    {
+        if(getPlatform().supportsOrderByInSubSelect())
+        {
+            return super.ensureColumnsOrderBy(columns, existingColumns, buf);
+        }
+        else
+        {
+            return existingColumns;
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message