db-ojb-dev mailing list archives

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

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

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

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java?view=diff&rev=524876&r1=524875&r2=524876
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlQueryStatement.java Mon
Apr  2 11:20:34 2007
@@ -490,7 +490,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())
         {
@@ -518,7 +518,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/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java?view=diff&rev=524876&r1=524875&r2=524876
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java (original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSelectStatement.java Mon
Apr  2 11:20:34 2007
@@ -337,10 +337,10 @@
             }
 
             groupByFields = query.getGroupBy();
-            ensureColumns(groupByFields, columnList);
+            ensureColumnsGroupBy(groupByFields, columnList);
             
             orderByFields = query.getOrderBy();
-            columnList = ensureColumns(orderByFields, columnList, stmt);
+            columnList = ensureColumnsOrderBy(orderByFields, columnList, stmt);
 
             stmt.append(" FROM ");
             appendTableWithJoins(getRootAlias(), where, stmt);

Modified: db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java
URL: http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java?view=diff&rev=524876&r1=524875&r2=524876
==============================================================================
--- db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java
(original)
+++ db/ojb/trunk/src/java/org/apache/ojb/broker/accesslayer/sql/SqlSubSelectStatement.java
Mon Apr  2 11:20:34 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