Quantcast

svn commit: r616989 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: query/EnclosingReportQuery.java query/ExistsCriteria.java query/InCriterion.java util/BrokerHelper.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

svn commit: r616989 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker: query/EnclosingReportQuery.java query/ExistsCriteria.java query/InCriterion.java util/BrokerHelper.java

Armin Waibel
Author: arminw
Date: Wed Jan 30 18:19:49 2008
New Revision: 616989

URL: http://svn.apache.org/viewvc?rev=616989&view=rev
Log:
fix: count query in combination with IN-clause, add missing preprocess(PersistenceBrokerInternal aPb) methods

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/EnclosingReportQuery.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/ExistsCriteria.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriterion.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/EnclosingReportQuery.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/EnclosingReportQuery.java?rev=616989&r1=616988&r2=616989&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/EnclosingReportQuery.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/EnclosingReportQuery.java Wed Jan 30 18:19:49 2008
@@ -23,6 +23,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.ojb.broker.PersistenceBrokerInternal;
+
 /**
  * Wrap a Query to support SQLSubSelect.
  * select count(*) from (select ... from ... where... )
@@ -41,6 +43,18 @@
     {
         query = aQuery;
         sql = anSql;
+    }
+
+    /**
+     * @see org.apache.ojb.broker.query.Query#preprocess(org.apache.ojb.broker.PersistenceBrokerInternal)
+     */
+    public void preprocess(PersistenceBrokerInternal aPb)
+    {
+        // is this required???
+        super.preprocess(aPb);
+
+        // this one is!!!!
+        query.preprocess(aPb);
     }
 
     public Query getQuery()

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/ExistsCriteria.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/ExistsCriteria.java?rev=616989&r1=616988&r2=616989&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/ExistsCriteria.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/ExistsCriteria.java Wed Jan 30 18:19:49 2008
@@ -1,5 +1,7 @@
 package org.apache.ojb.broker.query;
 
+import org.apache.ojb.broker.PersistenceBrokerInternal;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -40,6 +42,19 @@
     {
         super("", subQuery);
         m_negative = negative;
+    }
+
+    /**
+     * Preprocess the Criterion using a PersistenceBroker.
+     *
+     * @param aPb the PersistenceBroker
+     */
+    public void preprocess(PersistenceBrokerInternal aPb)
+    {
+        if (getValue() instanceof Query)
+        {
+            ((Query)getValue()).preprocess(aPb);
+        }
     }
 
     /*

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriterion.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriterion.java?rev=616989&r1=616988&r2=616989&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriterion.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriterion.java Wed Jan 30 18:19:49 2008
@@ -2,6 +2,8 @@
 
 import java.util.Collection;
 
+import org.apache.ojb.broker.PersistenceBrokerInternal;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -36,9 +38,22 @@
  {
  super(anAttribute, aValue, aClause);
  }
-
-
- /**
+
+    /**
+     * Preprocess the Criterion using a PersistenceBroker.
+     *
+     * @param aPb the PersistenceBroker
+     */
+    public void preprocess(PersistenceBrokerInternal aPb)
+    {
+        if (getValue() instanceof Query)
+        {
+            ((Query)getValue()).preprocess(aPb);
+        }
+    }
+
+
+    /**
  * @see org.apache.ojb.broker.query.SelectionCriteria#isBindable()
  * BRJ: empty Collection is bindable
  */

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java?rev=616989&r1=616988&r2=616989&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/util/BrokerHelper.java Wed Jan 30 18:19:49 2008
@@ -708,7 +708,16 @@
      */
     private Query getReportQueryByCriteriaCount(ReportQueryByCriteria aQuery)
     {
-        ReportQueryByCriteria countQuery = (ReportQueryByCriteria) getQueryByCriteriaCount(aQuery);
+        Query result = getQueryByCriteriaCount(aQuery);
+        ReportQueryByCriteria countQuery;
+        if(result instanceof EnclosingReportQuery)
+        {
+            countQuery = (ReportQueryByCriteria) ((EnclosingReportQuery) result).getQuery();
+        }
+        else
+        {
+            countQuery = (ReportQueryByCriteria) getQueryByCriteriaCount(aQuery);
+        }
 
         // BRJ: keep the original columns to build the Join
         countQuery.setJoinAttributes(aQuery.getAttributes());
@@ -720,7 +729,7 @@
             countQuery.addGroupBy((FieldHelper) iter.next());
         }
 
-        return countQuery;
+        return result;
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...