db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r368451 - in /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb: broker/query/BindableCriterion.java broker/query/InCriteria.java broker/query/SelectionCriteria.java odmg/oql/OQLQueryImpl.java
Date Thu, 12 Jan 2006 19:56:03 GMT
Author: brj
Date: Thu Jan 12 11:55:53 2006
New Revision: 368451

URL: http://svn.apache.org/viewcvs?rev=368451&view=rev
Log:
fix for oql binding problem of InCriteria

Added:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/BindableCriterion.java
Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriteria.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/SelectionCriteria.java
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java

Added: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/BindableCriterion.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/BindableCriterion.java?rev=368451&view=auto
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/BindableCriterion.java
(added)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/BindableCriterion.java
Thu Jan 12 11:55:53 2006
@@ -0,0 +1,39 @@
+package org.apache.ojb.broker.query;
+
+/* Copyright 2002-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Interface for Criterion that can be bound by OQLQuery.
+ * 
+ * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
+ * @version $Id:  $
+ */
+public interface BindableCriterion
+{
+    /**
+     * Used by the ODMG OQLQuery.bind() operation
+     * @return Returns a boolean indicator
+     */
+    public boolean isBound();
+
+    /**
+     * Sets the value of the criteria to newValue. 
+     * Used by the ODMG OQLQuery.bind() operation
+     */
+    public void bind(Object newValue);
+
+}
+

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriteria.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriteria.java?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriteria.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/InCriteria.java Thu
Jan 12 11:55:53 2006
@@ -1,7 +1,7 @@
 
 package org.apache.ojb.broker.query;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
  * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
  * @version $Id$
  */
-public class InCriteria extends Criteria
+public class InCriteria extends Criteria implements BindableCriterion
 {
     private static final long serialVersionUID = -2349356771591660674L;
 
@@ -171,6 +171,19 @@
     {
         String clause = isNegative() ? SelectionCriteria.NOT_IN : SelectionCriteria.IN;
         return "InCriteria:" + m_attribute + clause + super.toString();
+    }
+
+    /**
+     * sets the value of the criteria to newValue. Used by the ODMG OQLQuery.bind() operation
+     */
+    public void bind(Object newValue)
+    {
+        m_values = (Collection) newValue;
+    }
+
+    public boolean isBound()
+    {
+        return (m_values != null);
     }
     
     /**

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/SelectionCriteria.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/SelectionCriteria.java?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/SelectionCriteria.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/query/SelectionCriteria.java
Thu Jan 12 11:55:53 2006
@@ -3,7 +3,7 @@
 import java.util.List;
 import java.util.Map;
 
-/* Copyright 2002-2004 The Apache Software Foundation
+/* Copyright 2002-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@
  * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
  * @version $Id$
  */
-public abstract class SelectionCriteria extends AbstractCriterion
+public abstract class SelectionCriteria extends AbstractCriterion implements BindableCriterion
 {
 	static final long serialVersionUID = -5194901539702756536L;
 	

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java?rev=368451&r1=368450&r2=368451&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/odmg/oql/OQLQueryImpl.java Thu
Jan 12 11:55:53 2006
@@ -21,18 +21,18 @@
 import java.util.ListIterator;
 import java.util.Vector;
 
-import antlr.RecognitionException;
-import antlr.TokenStreamException;
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.ojb.broker.ManageableCollection;
 import org.apache.ojb.broker.PBKey;
 import org.apache.ojb.broker.PersistenceBroker;
 import org.apache.ojb.broker.PersistenceBrokerFactory;
 import org.apache.ojb.broker.accesslayer.OJBIterator;
 import org.apache.ojb.broker.query.BetweenCriteria;
+import org.apache.ojb.broker.query.BindableCriterion;
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.broker.query.ReportQuery;
-import org.apache.ojb.broker.query.SelectionCriteria;
 import org.apache.ojb.broker.util.collections.ManageableArrayList;
 import org.apache.ojb.broker.util.configuration.Configurable;
 import org.apache.ojb.broker.util.configuration.Configuration;
@@ -44,12 +44,13 @@
 import org.apache.ojb.odmg.PBCapsule;
 import org.apache.ojb.odmg.RuntimeObject;
 import org.apache.ojb.odmg.TransactionImpl;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.apache.commons.lang.SystemUtils;
 import org.odmg.QueryInvalidException;
-import org.odmg.Transaction;
 import org.odmg.QueryParameterCountInvalidException;
 import org.odmg.QueryParameterTypeInvalidException;
+import org.odmg.Transaction;
+
+import antlr.RecognitionException;
+import antlr.TokenStreamException;
 
 /**
  * The OQL query interface implementation.
@@ -123,7 +124,7 @@
     {
         try
         {
-            SelectionCriteria crit = (SelectionCriteria) getBindIterator().next();
+            BindableCriterion crit = (BindableCriterion) getBindIterator().next();
             crit.bind(parameter);
 
             // BRJ: bind is called twice for between
@@ -146,19 +147,22 @@
         while (e.hasMoreElements())
         {
             Object o = e.nextElement();
-            if (o instanceof Criteria)
+            if (o instanceof BindableCriterion)
+            {
+                BindableCriterion bc = (BindableCriterion) o;
+                if (!bc.isBound())
+                {
+                    acc.add(bc);
+                }                
+            }
+            else if (o instanceof Criteria)
             {
                 Criteria pc = (Criteria) o;
                 flatten(pc, acc);
             }
             else
             {
-                SelectionCriteria c = (SelectionCriteria) o;
-                // BRJ : only add bindable criteria
-                if (!c.isBound())
-                {
-                    acc.add(c);
-                }
+                throw new IllegalArgumentException("Dont't know how to handle: " + o);
             }
         }
         return acc;



---------------------------------------------------------------------
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