db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1329656 [1/4] - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/criteria/ torque-runtime/src/main/java/org/apache/torque/map/ torque-runtime/src/main/java/org/apache/torque/sql/ torque-runtime/src/main/java/org/...
Date Tue, 24 Apr 2012 11:52:51 GMT
Author: tfischer
Date: Tue Apr 24 11:52:50 2012
New Revision: 1329656

URL: http://svn.apache.org/viewvc?rev=1329656&view=rev
Log:
TORQUE-185: Allow subselects which do not reference a column
TORQUE-192: create method to set FROM clause from Criteria
TORQUE-193: Allow other types than Columns as left hand side of a comparison in Criteria.
TORQUE-194: create methods to create custom sql queries with prepared statement replacements

Added:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/FromElement.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectOrColumnPsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/ObjectPsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/objectbuilder/package.html
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/AbstractWhereClausePsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CurrentDateTimePsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/CustomBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/InBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/LikeBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/NullValueBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/StandardBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/VerbatimSqlConditionBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/WhereClausePsPartBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/whereclausebuilder/package.html
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SelectTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/SubselectTest.java
Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criterion.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/map/MapHelper.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/JoinBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/PreparedStatementPart.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/Query.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/WhereClauseExpression.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriteriaTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/QueryTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/sql/SqlBuilderTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DocsTest.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/datatypes/BooleanIntCharTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java?rev=1329656&r1=1329655&r2=1329656&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java Tue Apr 24 11:52:50 2012
@@ -31,7 +31,6 @@ import java.util.Map;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
 import org.apache.torque.Column;
-import org.apache.torque.ColumnImpl;
 import org.apache.torque.sql.OrderBy;
 import org.apache.torque.sql.Query;
 import org.apache.torque.sql.SqlBuilder;
@@ -149,6 +148,13 @@ public class Criteria
     /** The names of columns to add to a groupBy clause */
     private UniqueColumnList groupByColumns = new UniqueColumnList();
 
+    /**
+     * All "from" clauses. Empty if the from clause should be computed
+     * automatically.
+     */
+    private UniqueList<FromElement> fromElements
+            = new UniqueList<FromElement>();
+
     /** The having clause in a query. */
     private Criterion having = null;
 
@@ -228,28 +234,6 @@ public class Criteria
         return this;
     }
 
-   /**
-    * Add an AS clause to the select columns. Usage:
-    * <p>
-    * <code>
-    * Criteria myCrit = new Criteria();
-    * myCrit.addAsColumn(
-    *     &quot;alias&quot;,
-    *     &quot;ALIAS(&quot;+MyPeer.ID+&quot;)&quot;);
-    * </code>
-    * If the name already exists, it is replaced by the new clause.
-    *
-    * @param name wanted Name of the column
-    * @param clause SQL clause to select from the table
-    *
-    * @return A modified Criteria object.
-    */
-    public Criteria addAsColumn(String name, String clause)
-    {
-        asColumns.put(name, new ColumnImpl(clause));
-        return this;
-    }
-
     /**
      * Get the column aliases.
      *
@@ -326,26 +310,6 @@ public class Criteria
     }
 
     /**
-     * Method to return a criterion that is not added automatically
-     * to this Criteria.  This can be used to chain the
-     * Criterions to form a more complex where clause.
-     *
-     * @param column full name of column (for example TABLE.COLUMN).
-     * @param value The value to compare to.
-     * @param comparison the comparison to use.
-     *
-     * @return A Criterion.
-     *
-     * @deprecated use the constructor Criterion(Column, Object, SqlEnum)
-     *             instead.
-     */
-    public Criterion getNewCriterion(String column, Object value,
-            SqlEnum comparison)
-    {
-        return new Criterion(new ColumnImpl(column), value, comparison);
-    }
-
-    /**
      * Method to return criterion that is not added automatically
      * to this Criteria.  This can be used to chain the
      * Criterions to form a more complex where clause.
@@ -458,50 +422,6 @@ public class Criteria
     }
 
     /**
-     * Adds a join to the criteria, E.g. to create the condition
-     * <p>
-     * AND PROJECT.PROJECT_ID=FOO.PROJECT_ID
-     * <p> use <p>
-     * <code>
-     * criteria.addJoin("PROJECT.PROJECT_ID", "FOO.PROJECT_ID")
-     * </code>
-     *
-     * @param left A String with the left side of the join.
-     * @param right A String with the right side of the join.
-     * @return A modified Criteria object.
-     */
-    public Criteria addJoin(String left, String right)
-    {
-        return addJoin(left, right, null);
-    }
-
-    /**
-     * Adds a join to the criteria, E.g. to create the condition
-     * <p>
-     * PROJECT LEFT JOIN FOO ON PROJECT.PROJECT_ID=FOO.PROJECT_ID
-     * <p> use <p>
-     * <code>
-     * criteria.addJoin("PROJECT.PROJECT_ID", "FOO.PROJECT_ID",
-     *     Criteria.LEFT_JOIN);
-     * </code>
-     *
-     * @param left A String with the left side of the join.
-     * @param right A String with the right side of the join.
-     * @param operator The operator used for the join: must be one of null,
-     *        Criteria.LEFT_JOIN, Criteria.RIGHT_JOIN, Criteria.INNER_JOIN
-     * @return A modified Criteria object.
-     */
-    public Criteria addJoin(String left, String right, SqlEnum operator)
-    {
-        joins.add(new Join(
-                new ColumnImpl(left),
-                new ColumnImpl(right),
-                operator));
-
-        return this;
-    }
-
-    /**
      * Get the List of Joins.
      *
      * @return a List which contains objects of type Join, not null.
@@ -661,20 +581,6 @@ public class Criteria
     }
 
     /**
-     * Adds a select column.
-     *
-     * @param column The name of the select column, possibly prefixed
-     *        by the table name.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria addSelectColumn(String column)
-    {
-        selectColumns.add(new ColumnImpl(column));
-        return this;
-    }
-
-    /**
      * Return all select columns.
      *
      * @return An List with the names of the select columns, not null
@@ -708,19 +614,6 @@ public class Criteria
     }
 
     /**
-     * Add a group by clause.
-     *
-     * @param groupBy The name of the column to group by.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria addGroupByColumn(String groupBy)
-    {
-        groupByColumns.add(new ColumnImpl(groupBy));
-        return this;
-    }
-
-    /**
      * Get all group by columns.
      *
      * @return An UniqueList with the name of the groupBy clause, not null.
@@ -744,20 +637,6 @@ public class Criteria
     }
 
     /**
-     * Add order by column name, explicitly specifying ascending.
-     *
-     * @param column The name of the column to order by.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria addAscendingOrderByColumn(String column)
-    {
-        orderByColumns.add(
-                new OrderBy(new ColumnImpl(column), SqlEnum.ASC, false));
-        return this;
-    }
-
-    /**
      * Add an order by clause, explicitly specifying ascending.
      *
      * @param column The column to order by.
@@ -772,17 +651,15 @@ public class Criteria
     }
 
     /**
-     * Add order by column name, explicitly specifying ascending.
+     * Add order by column name, explicitly specifying descending.
      *
-     * @param column The name of the column to order by.
-     * @param ignoreCase whether to ignore case on String columns.
+     * @param column The column to order by.
      *
      * @return A modified Criteria object.
      */
-    public Criteria addAscendingOrderByColumn(String column, boolean ignoreCase)
+    public Criteria addDescendingOrderByColumn(Column column)
     {
-        orderByColumns.add(
-                new OrderBy(new ColumnImpl(column), SqlEnum.ASC, ignoreCase));
+        orderByColumns.add(new OrderBy(column, SqlEnum.DESC, false));
         return this;
     }
 
@@ -791,69 +668,59 @@ public class Criteria
      *
      * @param column The column to order by.
      *
+     * @param ignoreCase whether to ignore case on String columns.
+     *
      * @return A modified Criteria object.
      */
-    public Criteria addDescendingOrderByColumn(Column column)
+    public Criteria addDescendingOrderByColumn(
+            Column column,
+            boolean ignoreCase)
     {
-        orderByColumns.add(new OrderBy(column, SqlEnum.DESC, false));
+        orderByColumns.add(new OrderBy(column, SqlEnum.DESC, ignoreCase));
         return this;
     }
 
     /**
-     * Add order by column name, explicitly specifying descending.
-     *
-     * @param column The name of the column to order by.
+     * Get all order by columns.
      *
-     * @return A modified Criteria object.
+     * @return An UniqueList with the name of the order columns, not null.
      */
-    public Criteria addDescendingOrderByColumn(String column)
+    public UniqueList<OrderBy> getOrderByColumns()
     {
-        orderByColumns.add(
-                new OrderBy(new ColumnImpl(column), SqlEnum.DESC, false));
-        return this;
+        return orderByColumns;
     }
 
     /**
-     * Add order by column name, explicitly specifying descending.
+     * Get all elements in the from clause of the query.
      *
-     * @param column The column to order by.
-     *
-     * @param ignoreCase whether to ignore case on String columns.
-     *
-     * @return A modified Criteria object.
+     * @return An UniqueList with all from elements, not null.
+     *         Empty if the from elements should be computed automatically.
      */
-    public Criteria addDescendingOrderByColumn(
-            Column column,
-            boolean ignoreCase)
+    public UniqueList<FromElement> getFromElements()
     {
-        orderByColumns.add(new OrderBy(column, SqlEnum.DESC, ignoreCase));
-        return this;
+        return fromElements;
     }
 
     /**
-     * Add order by column name, explicitly specifying descending.
-     *
-     * @param column The name of the column to order by.
+     * Adds a table to the from clause, not using a joinType or joinCondition.
      *
-     * @return A modified Criteria object.
+     * @return the modified Criteria object.
      */
-    public Criteria addDescendingOrderByColumn(
-            String column,
-            boolean ignoreCase)
+    public Criteria addFrom(String tableName)
     {
-        orderByColumns.add(
-                new OrderBy(new ColumnImpl(column), SqlEnum.DESC, ignoreCase));
+        fromElements.add(new FromElement(tableName));
         return this;
     }
 
     /**
-     * Get all order by columns.
+     * Adds a new Element to the from clause.
      *
-     * @return An UniqueList with the name of the order columns, not null.
+     * @return the modified Criteria object.
      */
-    public UniqueList<OrderBy> getOrderByColumns()
+    public Criteria addFrom(FromElement fromElement)
     {
-        return orderByColumns;
+        fromElements.add(fromElement);
+        return this;
     }
 
     /**
@@ -915,6 +782,7 @@ public class Criteria
         equalsBuilder.append(criteria.selectModifiers, this.selectModifiers);
         equalsBuilder.append(criteria.selectColumns, this.selectColumns);
         equalsBuilder.append(criteria.orderByColumns, this.orderByColumns);
+        equalsBuilder.append(criteria.fromElements, this.fromElements);
         equalsBuilder.append(criteria.aliases, this.aliases);
         equalsBuilder.append(criteria.asColumns, this.asColumns);
         equalsBuilder.append(criteria.joins, this.joins);
@@ -939,6 +807,7 @@ public class Criteria
         hashCodeBuilder.append(selectModifiers);
         hashCodeBuilder.append(selectColumns);
         hashCodeBuilder.append(orderByColumns);
+        hashCodeBuilder.append(fromElements);
         hashCodeBuilder.append(aliases);
         hashCodeBuilder.append(asColumns);
         hashCodeBuilder.append(joins);
@@ -955,7 +824,8 @@ public class Criteria
         {
             return super.clone();
         }
-        catch (CloneNotSupportedException e) {
+        catch (CloneNotSupportedException e)
+        {
             // should not happen as we implement Cloneable
             throw new RuntimeException(e);
         }
@@ -1003,65 +873,49 @@ public class Criteria
 
     /**
      * This method ands the given condition with the current conditions
-     * in the Criteria. It is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add(&quot;column&quot;,
-     *                                      &quot;value&quot;);
-     * </code>
-     * An EQUAL comparison is used for column and value.
-     *
-     * @param column The column to run the comparison on.
-     * @param value The value to compare with the column, may be null.
-     *
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria add(Column column, Object value)
-    {
-        add(column, value, EQUAL);
-        return this;
-    }
-
-    /**
-     * This method ands the given condition with the current conditions
-     * in the Criteria. This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add(&quot;column&quot;,
-     *                                      &quot;value&quot;);
-     * </code>
+     * in the Criteria.
      * An EQUAL comparison is used for column and value.
      *
-     * @param column The column to run the comparison on.
-     * @param value The value to compare with the column, may be null.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      *
      * @return A modified Criteria object.
      * @deprecated The semantics of this method has changed.
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria add(String column, Object value)
+    public Criteria add(Object lValue, Object rValue)
     {
-        add(column, value, EQUAL);
+        add(lValue, rValue, EQUAL);
         return this;
     }
 
     /**
      * This method ands the given condition with the current conditions
-     * in the Criteria. It is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add(&quot;column&quot;,
-     *                                      &quot;value&quot;
-     *                                      Criteria.GREATER_THAN);
-     * </code>
-     * Any comparison can be used.
+     * in the Criteria.
      *
-     * @param column The column to run the comparison on.
-     * @param value The value to compare with the column, may be null.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param comparison The comparison operator.
      *
      * @return A modified Criteria object.
@@ -1070,45 +924,22 @@ public class Criteria
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria add(Column column, Object value, SqlEnum comparison)
+    public Criteria add(Object lValue, Object rValue, SqlEnum comparison)
     {
-        Criterion newCriterion = new Criterion(column, value, comparison);
-        if (topLevelCriterion == null)
+        Criterion newCriterion;
+        if (comparison == Criteria.CUSTOM)
         {
-            topLevelCriterion = newCriterion;
+            newCriterion = new Criterion(
+                    lValue,
+                    null,
+                    null,
+                    (String) rValue,
+                    null);
         }
         else
         {
-            topLevelCriterion.and(newCriterion);
+            newCriterion = new Criterion(lValue, rValue, comparison);
         }
-        return this;
-    }
-
-    /**
-     * This method ands the given condition with the current conditions
-     * in the Criteria. This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add(&quot;column&quot;,
-     *                                      &quot;value&quot;
-     *                                      Criteria.GREATER_THAN);
-     * </code>
-     * Any comparison can be used.
-     *
-     * @param column The column to run the comparison on.
-     * @param value The value to compare with the column, may be null.
-     * @param comparison The comparison operator.
-     *
-     * @return A modified Criteria object.
-     *
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria add(String column, Object value, SqlEnum comparison)
-    {
-        Column columnImpl = new ColumnImpl(column);
-        Criterion newCriterion = new Criterion(columnImpl, value, comparison);
         if (topLevelCriterion == null)
         {
             topLevelCriterion = newCriterion;
@@ -1128,31 +959,12 @@ public class Criteria
      * add(column, new GregorianCalendar(year, month, day), EQUAL);
      * </code>
      *
-     * @param column The column to compare the Date to.
-     * @param year An int with the year.
-     * @param month An int with the month. Month value is 0-based.
-     *        e.g., 0 for January
-     * @param day An int with the day.
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria addDate(Column column, int year, int month, int day)
-    {
-        add(column, new GregorianCalendar(year, month, day).getTime());
-        return this;
-    }
-
-    /**
-     * Convenience method to add a Date object specified by
-     * year, month, and date into the Criteria. Equal to
-     * <p>
-     * <code>
-     * add(column, new GregorianCalendar(year, month, day), EQUAL);
-     * </code>
-     *
-     * @param column The name of the column to compare the date to.
+     * @param lValue The value to compare the date to, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year An int with the year.
      * @param month An int with the month. Month value is 0-based.
      *        e.g., 0 for January
@@ -1162,9 +974,11 @@ public class Criteria
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria addDate(String column, int year, int month, int day)
+    public Criteria addDate(Object lValue, int year, int month, int day)
     {
-        add(column, new GregorianCalendar(year, month, day).getTime());
+        add(lValue,
+                new GregorianCalendar(year, month, day).getTime(),
+                EQUAL);
         return this;
     }
 
@@ -1176,52 +990,28 @@ public class Criteria
      * add(column, new GregorianCalendar(year, month, day), comparison);
      * </code>
      *
-     * @param column The column to run the comparison on
+     * @param lValue The value to compare the date to, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year An int with the year.
      * @param month An int with the month. Month value is 0-based.
      *        e.g., 0 for January
      * @param day An int with the day.
      * @param comparison String describing how to compare the column with
      *        the value.
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria addDate(Column column, int year, int month, int day,
-            SqlEnum comparison)
-    {
-        add(column, new GregorianCalendar(year, month, day).getTime(),
-                comparison);
-        return this;
-    }
-
-    /**
-     * Convenience method to add a Date object specified by
-     * year, month, and date into the Criteria.
-     * Equal to
-     *
-     * <p>
-     * <code>
-     * add(column, new GregorianCalendar(year, month, day), comparison);
-     * </code>
      *
-     * @param column The column to run the comparison on
-     * @param year An int with the year.
-     * @param month An int with the month. Month value is 0-based.
-     *        e.g., 0 for January
-     * @param day An int with the day.
-     * @param comparison String describing how to compare the column with
-     *        the value
      * @return A modified Criteria object.
      * @deprecated The semantics of this method has changed.
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria addDate(String column, int year, int month, int day,
+    public Criteria addDate(Object lValue, int year, int month, int day,
             SqlEnum comparison)
     {
-        add(column, new GregorianCalendar(year, month, day).getTime(),
+        add(lValue, new GregorianCalendar(year, month, day).getTime(),
                 comparison);
         return this;
     }
@@ -1236,193 +1026,119 @@ public class Criteria
      * criteria.addIn(FooPeer.NAME, new String[] {'FOO', 'BAR', 'ZOW'});
      * </code>
      *
-     * @param column The column to run the comparison on
-     * @param values An Object[] with the allowed values.
+     * @param lValue The value which is checked for containment, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to check against, not null.
+     *
      * @return A modified Criteria object.
      * @deprecated The semantics of this method has changed.
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria addIn(Column column, Object[] values)
+    public Criteria addIn(Object lValue, Object[] rValues)
     {
-        add(column, values, Criteria.IN);
+        add(lValue, rValues, Criteria.IN);
         return this;
     }
 
     /**
-     * Adds an 'IN' clause with the value supplied as an Object
-     * array.  For example, to add the condition
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a Collection.
+     *  For example, to add the condition
      * <p>
      * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
      * <p> use <p>
      * <code>
-     * criteria.addIn("FOO.NAME", new String[] {'FOO', 'BAR', 'ZOW'});
+     * criteria.addIn(FooPeer.NAME, values);
      * </code>
      *
-     * @param column The column to run the comparison on
-     * @param values An Object[] with the allowed values.
+     * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
+     *
+     * @param lValue The value which is checked for containment, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to check against, not null.
+     *
      * @return A modified Criteria object.
      * @deprecated The semantics of this method has changed.
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria addIn(String column, Object[] values)
+    public Criteria addIn(Object lValue, Collection<?> rValues)
     {
-        add(column, values, Criteria.IN);
+        add(lValue, rValues, Criteria.IN);
         return this;
     }
 
+
     /**
-    /**
-     * Adds an 'IN' clause with the criteria supplied as a Collection.
-     *  For example, to add the condition
+     * Adds an 'NOT IN' clause with the value supplied as an Object
+     * array.  For example, to add the condition
      * <p>
-     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
      * <p> use <p>
      * <code>
-     * criteria.addIn(FooPeer.NAME, values);
+     * criteria.addNotIn(FooPeer.NAME, new String[] {'FOO', 'BAR', 'ZOW'});
      * </code>
      *
-     * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
-     *
-     * @param column The column to run the comparison on
-     * @param values A Collection with the allowed values.
+     * @param lValue The value which is checked for containment, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to check against, not null.
      *
      * @return A modified Criteria object.
      * @deprecated The semantics of this method has changed.
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria addIn(Column column, Collection<?> values)
+    public Criteria addNotIn(Object lValue, Object[] rValues)
     {
-        add(column, values, Criteria.IN);
+        add(lValue, rValues, Criteria.NOT_IN);
         return this;
     }
 
     /**
-     * Adds an 'IN' clause with the criteria supplied as a Collection.
+    /**
+     * Adds an 'NOT IN' clause with the criteria supplied as a Collection.
      *  For example, to add the condition
      * <p>
-     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
      * <p> use <p>
      * <code>
-     * criteria.addIn("FOO.NAME", values);
+     * criteria.addNotIn(FooPeer.NAME, values);
      * </code>
      *
      * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
      *
-     * @param column The column to run the comparison on
-     * @param values A Collection with the allowed values.
+     * @param lValue The value which is checked for containment, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to check against, not null.
      *
      * @return A modified Criteria object.
      * @deprecated The semantics of this method has changed.
      *             This method will be removed in a future version of Torque.
      *             Use and(...) or where(...) instead.
      */
-    public Criteria addIn(String column, Collection<?> values)
+    public Criteria addNotIn(Object lValue, Collection<?> rValues)
     {
-        add(column, values, Criteria.IN);
+        add(lValue, rValues, Criteria.NOT_IN);
         return this;
     }
 
-    /**
-     * Adds an 'NOT IN' clause with the value supplied as an Object
-     * array.  For example, to add the condition
-     * <p>
-     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
-     * <p> use <p>
-     * <code>
-     * criteria.addNotIn(FooPeer.NAME, new String[] {'FOO', 'BAR', 'ZOW'});
-     * </code>
-     *
-     * @param column The column to run the comparison on
-     * @param values An Object[] with the disallowed values.
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria addNotIn(Column column, Object[] values)
-    {
-        add(column, values, Criteria.NOT_IN);
-        return this;
-    }
-
-    /**
-     * Adds an 'NOT IN' clause with the value supplied as an Object
-     * array.  For example, to add the condition
-     * <p>
-     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
-     * <p> use <p>
-     * <code>
-     * criteria.addNotIn("FOO.NAME", new String[] {'FOO', 'BAR', 'ZOW'});
-     * </code>
-     *
-     * @param column The column to run the comparison on
-     * @param values An Object[] with the disallowed values.
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria addNotIn(String column, Object[] values)
-    {
-        add(column, values, Criteria.NOT_IN);
-        return this;
-    }
-
-    /**
-    /**
-     * Adds an 'NOT IN' clause with the criteria supplied as a Collection.
-     *  For example, to add the condition
-     * <p>
-     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
-     * <p> use <p>
-     * <code>
-     * criteria.addNotIn(FooPeer.NAME, values);
-     * </code>
-     *
-     * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
-     *
-     * @param column The column to run the comparison on
-     * @param values A Collection with the disallowed values.
-     *
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria addNotIn(Column column, Collection<?> values)
-    {
-        add(column, values, Criteria.NOT_IN);
-        return this;
-    }
-
-    /**
-     * Adds an 'NOT IN' clause with the criteria supplied as a Collection.
-     *  For example, to add the condition
-     * <p>
-     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
-     * <p> use <p>
-     * <code>
-     * criteria.addNotIn("FOO.NAME", values);
-     * </code>
-     *
-     * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
-     *
-     * @param column The column to run the comparison on
-     * @param values A Collection with the allowed values.
-     *
-     * @return A modified Criteria object.
-     * @deprecated The semantics of this method has changed.
-     *             This method will be removed in a future version of Torque.
-     *             Use and(...) or where(...) instead.
-     */
-    public Criteria addNotIn(String column, Collection<?> values)
-    {
-        add(column, values, Criteria.NOT_IN);
-        return this;
-    }
 
     /*
      * ------------------------------------------------------------------------
@@ -1462,106 +1178,71 @@ public class Criteria
 
     /**
      * "AND"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().and(column, &quot;value&quot;);
-     * </code>
-     *
-     * An EQUAL comparison is used for column and value.
+     * An EQUAL comparison is used for comparing rValue and lValue.
      *
-     * @param column The column to run the comparison on
-     * @param value The value to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      *
      * @return A modified Criteria object.
      */
-    public Criteria and(Column column, Object value)
+    public Criteria and(Object lValue, Object rValue)
     {
-        return and(column, value, EQUAL);
+        return and(lValue, rValue, EQUAL);
     }
 
     /**
      * "AND"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().and("column", &quot;value&quot;);
-     * </code>
-     *
-     * An EQUAL comparison is used for column and value.
-     *
-     * @param column The name of the column to run the comparison on
-     * @param value The value to compare against.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria and(String column, Object value)
-    {
-        return and(new ColumnImpl(column), value, EQUAL);
-    }
-
-    /**
-     * "AND"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().and(column,
-     *                                      &quot;value&quot;
-     *                                      Criteria.GREATER_THAN);
-     * </code>
-     *
-     * Any comparison can be used.
      *
-     * @param column The column to run the comparison on
-     * @param value The value to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param comparison the comparison, or <code>Criteria.CUSTOM</code>
-     *        to specify the expression manually in the value parameter.
+     *        to specify the expression manually in the rValue parameter.
      *
      * @return A modified Criteria object.
      */
-    public Criteria and(Column column, Object value, SqlEnum comparison)
+    public Criteria and(Object lValue, Object rValue, SqlEnum comparison)
     {
-        Criterion nc = new Criterion(column, value, comparison);
-        if (topLevelCriterion == null)
+        Criterion newCriterion;
+        if (comparison == Criteria.CUSTOM)
         {
-            topLevelCriterion = nc;
+            newCriterion = new Criterion(
+                    lValue,
+                    null,
+                    null,
+                    (String) rValue,
+                    null);
         }
         else
         {
-            topLevelCriterion.and(nc);
+            newCriterion = new Criterion(lValue, rValue, comparison);
         }
-        return this;
-    }
-
-    /**
-     * "AND"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().and(&quot;column&quot;,
-     *                                      &quot;value&quot;
-     *                                      Criteria.GREATER_THAN);
-     * </code>
-     *
-     * Any comparison can be used.
-     *
-     * @param column The name of the column to run the comparison on
-     * @param value The value to compare against.
-     * @param comparison the comparison, or <code>Criteria.CUSTOM</code>
-     *        to specify the expression manually in the value parameter.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria and(String column, Object value, SqlEnum comparison)
-    {
-        Criterion nc = new Criterion(new ColumnImpl(column), value, comparison);
         if (topLevelCriterion == null)
         {
-            topLevelCriterion = nc;
+            topLevelCriterion = newCriterion;
         }
         else
         {
-            topLevelCriterion.and(nc);
+            topLevelCriterion.and(newCriterion);
         }
         return this;
     }
@@ -1574,35 +1255,21 @@ public class Criteria
      * and(column, new GregorianCalendar(year, month,date), EQUAL);
      * </code>
      *
-     * @param column The column to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year The year to compare to.
      * @param month The month to compare to.
      * @param day The day to compare to.
-     * @return A modified Criteria object.
-     */
-    public Criteria andDate(Column column, int year, int month, int day)
-    {
-        return and(column, new GregorianCalendar(year, month, day).getTime(),
-                Criteria.EQUAL);
-    }
-
-    /**
-     * Convenience method to AND a new date comparison with the conditions
-     * in this Criteria. Equal to
-     * <p>
-     * <code>
-     * and(column, new GregorianCalendar(year, month,date), EQUAL);
-     * </code>
      *
-     * @param column The name of the column to compare against.
-     * @param year The year to compare to.
-     * @param month The month to compare to.
-     * @param day The day to compare to.
      * @return A modified Criteria object.
      */
-    public Criteria andDate(String column, int year, int month, int day)
+    public Criteria andDate(Object lValue, int year, int month, int day)
     {
-        return and(new ColumnImpl(column),
+        return and(lValue,
                 new GregorianCalendar(year, month, day).getTime(),
                 Criteria.EQUAL);
     }
@@ -1615,40 +1282,23 @@ public class Criteria
      * and(column, new GregorianCalendar(year, month,date), comparison);
      * </code>
      *
-     * @param column The column to run the comparison on.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year The year to compare to.
      * @param month The month to compare to.
      * @param day The day to compare to.
      * @param comparison The comparison operator.
-     * @return A modified Criteria object.
-     */
-    public Criteria andDate(Column column, int year, int month, int date,
-            SqlEnum comparison)
-    {
-        return and(column,
-                new GregorianCalendar(year, month, date).getTime(),
-                comparison);
-    }
-
-    /**
-     * Convenience method to AND a new date comparison with the conditions
-     * in this Criteria. Equal to
-     * <p>
-     * <code>
-     * and(column, new GregorianCalendar(year, month,date), comparison);
-     * </code>
      *
-     * @param column The name of the column to run the comparison on.
-     * @param year The year to compare to.
-     * @param month The month to compare to.
-     * @param day The day to compare to.
-     * @param comparison The comparison operator.
      * @return A modified Criteria object.
      */
-    public Criteria andDate(String column, int year, int month, int date,
+    public Criteria andDate(Object lValue, int year, int month, int date,
             SqlEnum comparison)
     {
-        return and(new ColumnImpl(column),
+        return and(lValue,
                 new GregorianCalendar(year, month, date).getTime(),
                 comparison);
     }
@@ -1661,30 +1311,19 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria andIn(Column column, Object[] values)
-    {
-        return and(column, values, Criteria.IN);
-    }
-
-    /**
-     * Convenience method to AND a "in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME IN (${values})
-     * <p>
-     * where ${values} contains the values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria andIn(String column, Object[] values)
+    public Criteria andIn(Object lValue, Object[] rValues)
     {
-        return and(new ColumnImpl(column), values, Criteria.IN);
+        return and(lValue, rValues, Criteria.IN);
     }
 
     /**
@@ -1695,30 +1334,19 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria andIn(Column column, Collection<?> values)
-    {
-        return and(column, values, Criteria.IN);
-    }
-
-    /**
-     * Convenience method to AND a "in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME IN (${values})
-     * <p>
-     * where ${values} contains the values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria andIn(String column, Collection<?> values)
+    public Criteria andIn(Object lValue, Collection<?> rValues)
     {
-        return and(new ColumnImpl(column), values, Criteria.IN);
+        return and(lValue, rValues, Criteria.IN);
     }
 
     /**
@@ -1729,13 +1357,19 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
+     *
      * @return A modified Criteria object.
      */
-    public Criteria andNotIn(Column column, Object[] values)
+    public Criteria andNotIn(Object lValue, Object[] rValues)
     {
-        return and(column, values, Criteria.NOT_IN);
+        return and(lValue, rValues, Criteria.NOT_IN);
     }
 
     /**
@@ -1746,47 +1380,77 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
+     *
      * @return A modified Criteria object.
      */
-    public Criteria andNotIn(String column, Object[] values)
+    public Criteria andNotIn(Object lValue, Collection<?> rValues)
     {
-        return and(new ColumnImpl(column), values, Criteria.NOT_IN);
+        return and(lValue, rValues, Criteria.NOT_IN);
     }
 
     /**
-     * Convenience method to AND a "not in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME NOT IN (${values})
+     * Ands a verbatim sql condition to this Criteria.
+     * This is used as follows:
      * <p>
-     * where ${values} contains the values to compare against.
+     * <code>
+     * Criteria criteria = ...;
+     * criteria.andVerbatimSql("count(foo.x) = ?", new Object[] {0});
+     * </code>
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
+     * @param sql the verbatim SQL to use.
+     * @param replacements the replacements for the "?" placeholders in SQL.
+     *
+     * @return the modified Criteria.
      */
-    public Criteria andNotIn(Column column, Collection<?> values)
+    public Criteria andVerbatimSql(String sql, Object[] replacements)
     {
-        return and(column, values, Criteria.NOT_IN);
+        Criterion criterion
+                = new Criterion(null, null, null, sql, replacements);
+        and(criterion);
+        return this;
     }
 
     /**
-     * Convenience method to AND a "not in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME NOT IN (${values})
+     * ANDs a verbatim sql condition to this Criteria.
+     * This is used as follows:
      * <p>
-     * where ${values} contains the values to compare against.
-     *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria andNotIn(String column, Collection<?> values)
-    {
-        return and(new ColumnImpl(column), values, Criteria.NOT_IN);
+     * <code>
+     * Criteria criteria = new Criteria();
+     * criteria.andVerbatimSql(
+     *     "count(foo.x) = ?",
+     *     new Object[] {0},
+     *     FooPeer.X,
+     *     null);
+     * </code>
+     *
+     * @param sql the verbatim SQL to use.
+     * @param replacements the replacements for the "?" placeholders in SQL.
+     * @param toAddToFromClause1 a column to add to from clause, may be null.
+     * @param toAddToFromClause2 a column to add to from clause, may be null.
+     *
+     * @return the modified Criteria.
+     */
+    public Criteria andVerbatimSql(
+            String sql,
+            Object[] replacements,
+            Column toAddToFromClause1,
+            Column toAddToFromClause2)
+    {
+        Criterion criterion = new Criterion(
+                toAddToFromClause1,
+                toAddToFromClause2,
+                null,
+                sql,
+                replacements);
+        and(criterion);
+        return this;
     }
 
     /*
@@ -1827,106 +1491,71 @@ public class Criteria
 
     /**
      * "OR"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().or(column, &quot;value&quot;);
-     * </code>
-     *
-     * An EQUAL comparison is used for column and value.
-     *
-     * @param column The column to run the comparison on
-     * @param value The value to compare against.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria or(Column column, Object value)
-    {
-        return or(column, value, EQUAL);
-    }
-
-    /**
-     * "OR"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().or("column", &quot;value&quot;);
-     * </code>
-     *
      * An EQUAL comparison is used for column and value.
      *
-     * @param column The name of the column to run the comparison on
-     * @param value The value to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      *
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, Object value)
+    public Criteria or(Object lValue, Object rValue)
     {
-        return or(new ColumnImpl(column), value, EQUAL);
+        return or(lValue, rValue, EQUAL);
     }
 
     /**
      * "OR"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().or(column,
-     *                                      &quot;value&quot;
-     *                                      Criteria.GREATER_THAN);
-     * </code>
      *
-     * Any comparison can be used.
-     *
-     * @param column The column to run the comparison on
-     * @param value The value to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param comparison the comparison, or <code>Criteria.CUSTOM</code>
      *        to specify the expression manually in the value parameter.
      *
      * @return A modified Criteria object.
      */
-    public Criteria or(Column column, Object value, SqlEnum comparison)
+    public Criteria or(Object lValue, Object rValue, SqlEnum comparison)
     {
-        Criterion nc = new Criterion(column, value, comparison);
-        if (topLevelCriterion == null)
+        Criterion newCriterion;
+        if (comparison == Criteria.CUSTOM)
         {
-            topLevelCriterion = nc;
+            newCriterion = new Criterion(
+                    lValue,
+                    null,
+                    null,
+                    (String) rValue,
+                    null);
         }
         else
         {
-            topLevelCriterion.or(nc);
+            newCriterion = new Criterion(lValue, rValue, comparison);
         }
-        return this;
-    }
-
-    /**
-     * "OR"s a new condition with the conditions in this Criteria.
-     * This is used as follows:
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().or(&quot;column&quot;,
-     *                                      &quot;value&quot;
-     *                                      Criteria.GREATER_THAN);
-     * </code>
-     *
-     * Any comparison can be used.
-     *
-     * @param column The name of the column to run the comparison on
-     * @param value The value to compare against.
-     * @param comparison the comparison, or <code>Criteria.CUSTOM</code>
-     *        to specify the expression manually in the value parameter.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria or(String column, Object value, SqlEnum comparison)
-    {
-        Criterion nc = new Criterion(new ColumnImpl(column), value, comparison);
         if (topLevelCriterion == null)
         {
-            topLevelCriterion = nc;
+            topLevelCriterion = newCriterion;
         }
         else
         {
-            topLevelCriterion.or(nc);
+            topLevelCriterion.or(newCriterion);
         }
         return this;
     }
@@ -1939,35 +1568,21 @@ public class Criteria
      * or(column, new GregorianCalendar(year, month,date), EQUAL);
      * </code>
      *
-     * @param column The column to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year The year to compare to.
      * @param month The month to compare to.
      * @param day The day to compare to.
-     * @return A modified Criteria object.
-     */
-    public Criteria orDate(Column column, int year, int month, int day)
-    {
-        return or(column, new GregorianCalendar(year, month, day).getTime(),
-                Criteria.EQUAL);
-    }
-
-    /**
-     * Convenience method to OR a new date comparison with the conditions
-     * in this Criteria. Equal to
-     * <p>
-     * <code>
-     * or(column, new GregorianCalendar(year, month,date), EQUAL);
-     * </code>
      *
-     * @param column The name of the column to compare against.
-     * @param year The year to compare to.
-     * @param month The month to compare to.
-     * @param day The day to compare to.
      * @return A modified Criteria object.
      */
-    public Criteria orDate(String column, int year, int month, int day)
+    public Criteria orDate(Object lValue, int year, int month, int day)
     {
-        return or(new ColumnImpl(column),
+        return or(lValue,
                 new GregorianCalendar(year, month, day).getTime(),
                 Criteria.EQUAL);
     }
@@ -1980,40 +1595,23 @@ public class Criteria
      * or(column, new GregorianCalendar(year, month,date), comparison);
      * </code>
      *
-     * @param column The column to run the comparison on.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year The year to compare to.
      * @param month The month to compare to.
      * @param day The day to compare to.
      * @param comparison The comparison operator.
-     * @return A modified Criteria object.
-     */
-    public Criteria orDate(Column column, int year, int month, int date,
-            SqlEnum comparison)
-    {
-        return or(column,
-                new GregorianCalendar(year, month, date).getTime(),
-                comparison);
-    }
-
-    /**
-     * Convenience method to OR a new date comparison with the conditions
-     * in this Criteria. Equal to
-     * <p>
-     * <code>
-     * or(column, new GregorianCalendar(year, month,date), comparison);
-     * </code>
      *
-     * @param column The name of the column to run the comparison on.
-     * @param year The year to compare to.
-     * @param month The month to compare to.
-     * @param day The day to compare to.
-     * @param comparison The comparison operator.
      * @return A modified Criteria object.
      */
-    public Criteria orDate(String column, int year, int month, int date,
+    public Criteria orDate(Object lValue, int year, int month, int date,
             SqlEnum comparison)
     {
-        return or(new ColumnImpl(column),
+        return or(lValue,
                 new GregorianCalendar(year, month, date).getTime(),
                 comparison);
     }
@@ -2026,30 +1624,19 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria orIn(Column column, Object[] values)
-    {
-        return or(column, values, Criteria.IN);
-    }
-
-    /**
-     * Convenience method to OR a "in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME IN (${values})
-     * <p>
-     * where ${values} contains the values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria orIn(String column, Object[] values)
+    public Criteria orIn(Object lValue, Object[] rValues)
     {
-        return or(new ColumnImpl(column), values, Criteria.IN);
+        return or(lValue, rValues, Criteria.IN);
     }
 
     /**
@@ -2060,30 +1647,19 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria orIn(Column column, Collection<?> values)
-    {
-        return or(column, values, Criteria.IN);
-    }
-
-    /**
-     * Convenience method to OR a "in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME IN (${values})
-     * <p>
-     * where ${values} contains the values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria orIn(String column, Collection<?> values)
+    public Criteria orIn(Object lValue, Collection<?> rValues)
     {
-        return or(new ColumnImpl(column), values, Criteria.IN);
+        return or(lValue, rValues, Criteria.IN);
     }
 
     /**
@@ -2094,13 +1670,19 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
+     *
      * @return A modified Criteria object.
      */
-    public Criteria orNotIn(Column column, Object[] values)
+    public Criteria orNotIn(Object lValue, Object[] rValues)
     {
-        return or(column, values, Criteria.NOT_IN);
+        return or(lValue, rValues, Criteria.NOT_IN);
     }
 
     /**
@@ -2111,47 +1693,77 @@ public class Criteria
      * <p>
      * where ${values} contains the values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
+     *
      * @return A modified Criteria object.
      */
-    public Criteria orNotIn(String column, Object[] values)
+    public Criteria orNotIn(Object lValue, Collection<?> rValues)
     {
-        return or(new ColumnImpl(column), values, Criteria.NOT_IN);
+        return or(lValue, rValues, Criteria.NOT_IN);
     }
 
     /**
-     * Convenience method to OR a "not in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME NOT IN (${values})
+     * ORs a verbatim sql condition to this Criteria.
+     * This is used as follows:
      * <p>
-     * where ${values} contains the values to compare against.
+     * <code>
+     * Criteria criteria = ...;
+     * criteria.orVerbatimSql("count(foo.x) = ?", new Object[] {0});
+     * </code>
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
+     * @param sql the verbatim SQL to use.
+     * @param replacements the replacements for the "?" placeholders in SQL.
+     *
+     * @return the modified Criteria.
      */
-    public Criteria orNotIn(Column column, Collection<?> values)
+    public Criteria orVerbatimSql(String sql, Object[] replacements)
     {
-        return or(column, values, Criteria.NOT_IN);
+        Criterion criterion
+                = new Criterion(null, null, null, sql, replacements);
+        or(criterion);
+        return this;
     }
 
     /**
-     * Convenience method to OR a "not in" comparison with the conditions
-     * in this Criteria. Creates the condition
-     * <p>
-     * FOO.NAME NOT IN (${values})
+     * ORs a verbatim sql condition to this Criteria.
+     * This is used as follows:
      * <p>
-     * where ${values} contains the values to compare against.
-     *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria orNotIn(String column, Collection<?> values)
-    {
-        return or(new ColumnImpl(column), values, Criteria.NOT_IN);
+     * <code>
+     * Criteria criteria = new Criteria();
+     * criteria.orVerbatimSql(
+     *     "count(foo.x) = ?",
+     *     new Object[] {0},
+     *     FooPeer.X,
+     *     null);
+     * </code>
+     *
+     * @param sql the verbatim SQL to use.
+     * @param replacements the replacements for the "?" placeholders in SQL.
+     * @param toAddToFromClause1 a column to add to from clause, may be null.
+     * @param toAddToFromClause2 a column to add to from clause, may be null.
+     *
+     * @return the modified Criteria.
+     */
+    public Criteria orVerbatimSql(
+            String sql,
+            Object[] replacements,
+            Column toAddToFromClause1,
+            Column toAddToFromClause2)
+    {
+        Criterion criterion = new Criterion(
+                toAddToFromClause1,
+                toAddToFromClause2,
+                null,
+                sql,
+                replacements);
+        or(criterion);
+        return this;
     }
 
     /*
@@ -2181,29 +1793,24 @@ public class Criteria
      * Equivalent to <code>#and(Column, Object)</code> but better to read
      * if this is the first condition to be added to the Criteria.
      *
-     * @param column The column to run the comparison on
-     * @param value The value to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      *
      * @return A modified Criteria object.
      */
-    public Criteria where(Column column, Object value)
+    public Criteria where(Object lValue, Object rValue)
     {
-        return and(column, value);
-    }
-
-    /**
-     * "AND"s a new condition with the conditions in this Criteria.
-     * Equivalent to <code>#and(String, Object)</code> but better to read
-     * if this is the first condition to be added to the Criteria.
-     *
-     * @param column The name of the column to run the comparison on
-     * @param value The value to compare against.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria where(String column, Object value)
-    {
-        return and(new ColumnImpl(column), value);
+        return and(lValue, rValue);
     }
 
     /**
@@ -2211,33 +1818,26 @@ public class Criteria
      * Equivalent to <code>#and(Column, Object, SqlEnum)</code> but better to
      * read if this is the first condition to be added to the Criteria.
      *
-     * @param column The column to run the comparison on
-     * @param value The value to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValue The right hand side of the comparison, may be null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param comparison the comparison, or <code>Criteria.CUSTOM</code>
      *        to specify the expression manually in the value parameter.
      *
      * @return A modified Criteria object.
      */
-    public Criteria where(Column column, Object value, SqlEnum comparison)
+    public Criteria where(Object lValue, Object rValue, SqlEnum comparison)
     {
-        return and(column, value, comparison);
-    }
-
-    /**
-     * "AND"s a new condition with the conditions in this Criteria.
-     * Equivalent to <code>#and(String, Object, SqlEnum)</code> but better to
-     * read if this is the first condition to be added to the Criteria.
-     *
-     * @param column The name of the column to run the comparison on
-     * @param value The value to compare against.
-     * @param comparison the comparison, or <code>Criteria.CUSTOM</code>
-     *        to specify the expression manually in the value parameter.
-     *
-     * @return A modified Criteria object.
-     */
-    public Criteria where(String column, Object value, SqlEnum comparison)
-    {
-        return and(new ColumnImpl(column), value, comparison);
+        return and(lValue, rValue, comparison);
     }
 
     /**
@@ -2246,32 +1846,21 @@ public class Criteria
      * <code>#andDate(Column, int, int, int)</code> but better to read
      * if this is the first condition to be added to the Criteria.
      *
-     * @param column The column to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year The year to compare to.
      * @param month The month to compare to.
      * @param day The day to compare to.
-     * @return A modified Criteria object.
-     */
-    public Criteria whereDate(Column column, int year, int month, int day)
-    {
-        return andDate(column, year, month, day);
-    }
-
-    /**
-     * Convenience method to AND a new date comparison with the conditions
-     * in this Criteria. Equivalent to
-     * <code>#andDate(String, int, int, int)</code> but better to read
-     * if this is the first condition to be added to the Criteria.
      *
-     * @param column The name of the column to compare against.
-     * @param year The year to compare to.
-     * @param month The month to compare to.
-     * @param day The day to compare to.
      * @return A modified Criteria object.
      */
-    public Criteria whereDate(String column, int year, int month, int day)
+    public Criteria whereDate(Object lValue, int year, int month, int day)
     {
-        return andDate(new ColumnImpl(column), year, month, day);
+        return andDate(lValue, year, month, day);
     }
 
     /**
@@ -2280,36 +1869,23 @@ public class Criteria
      * <code>#andDate(Column, int, int, int, SqlEnum)</code> but better to read
      * if this is the first condition to be added to the Criteria.
      *
-     * @param column The column to run the comparison on.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
      * @param year The year to compare to.
      * @param month The month to compare to.
      * @param day The day to compare to.
      * @param comparison The comparison operator.
-     * @return A modified Criteria object.
-     */
-    public Criteria whereDate(Column column, int year, int month, int day,
-            SqlEnum comparison)
-    {
-        return andDate(column, year, month, day, comparison);
-    }
-
-    /**
-     * Convenience method to AND a new date comparison with the conditions
-     * in this Criteria. Equivalent to
-     * <code>#andDate(String, int, int, int, SqlEnum)</code> but better to read
-     * if this is the first condition to be added to the Criteria.
      *
-     * @param column The name of the column to run the comparison on.
-     * @param year The year to compare to.
-     * @param month The month to compare to.
-     * @param day The day to compare to.
-     * @param comparison The comparison operator.
      * @return A modified Criteria object.
      */
-    public Criteria whereDate(String column, int year, int month, int day,
+    public Criteria whereDate(Object lValue, int year, int month, int day,
             SqlEnum comparison)
     {
-        return andDate(new ColumnImpl(column), year, month, day, comparison);
+        return andDate(lValue, year, month, day, comparison);
     }
 
     /**
@@ -2318,28 +1894,19 @@ public class Criteria
      * but better to read if this is the first condition to be added
      * to the Criteria.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria whereIn(Column column, Object[] values)
-    {
-        return andIn(column, values);
-    }
-
-    /**
-     * Convenience method to AND a "in" comparison with the conditions
-     * in this Criteria. Equivalent to <code>#andIn(String, Object[])</code>
-     * but better to read if this is the first condition to be added
-     * to the Criteria.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria whereIn(String column, Object[] values)
+    public Criteria whereIn(Object lValue, Object[] rValues)
     {
-        return andIn(new ColumnImpl(column), values);
+        return andIn(lValue, rValues);
     }
 
     /**
@@ -2348,28 +1915,19 @@ public class Criteria
      * but better to read if this is the first condition to be added
      * to the Criteria.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria whereIn(Column column, Collection<?> values)
-    {
-        return andIn(column, values);
-    }
-
-    /**
-     * Convenience method to AND a "in" comparison with the conditions
-     * in this Criteria. Equivalent to <code>#andIn(String, Collection)</code>
-     * but better to read if this is the first condition to be added
-     * to the Criteria.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param lValues The values to compare against.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria whereIn(String column, Collection<?> values)
+    public Criteria whereIn(Object lValue, Collection<?> rValues)
     {
-        return andIn(new ColumnImpl(column), values);
+        return andIn(lValue, rValues);
     }
 
     /**
@@ -2378,57 +1936,102 @@ public class Criteria
      * <code>#andNotIn(Column, Object[])</code> but better to read
      * if this is the first condition to be added to the Criteria.
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
+     *
      * @return A modified Criteria object.
      */
-    public Criteria whereNotIn(Column column, Object[] values)
+    public Criteria whereNotIn(Object lValue, Object[] rValues)
     {
-        return andNotIn(column, values);
+        return andNotIn(lValue, rValues);
     }
 
     /**
      * Convenience method to AND a "not in" comparison with the conditions
      * in this Criteria. Equivalent to
-     * <code>#andNotIn(String, Object[])</code> but better to read
+     * <code>#andNotIn(Column, Collection)</code> but better to read
      * if this is the first condition to be added to the Criteria.
      *
-     * @param column The name of the column to run the comparison on
-     * @param values The values to compare against.
+     * @param lValue The left hand side of the comparison, not null.
+     *        If this object implements the Column interface, it is interpreted
+     *        as a (pseudo)column.
+     *        If this object is c Criteria, it is interpreted as a subselect.
+     *        In all other cases, (e.G. string object), it is interpreted as
+     *        literal value.
+     * @param rValues The values to compare against.
      * @return A modified Criteria object.
      */
-    public Criteria whereNotIn(String column, Object[] values)
+    public Criteria whereNotIn(Object lValue, Collection<?> rValues)
     {
-        return andNotIn(new ColumnImpl(column), values);
+        return andNotIn(lValue, rValues);
     }
 
     /**
-     * Convenience method to AND a "not in" comparison with the conditions
-     * in this Criteria. Equivalent to
-     * <code>#andNotIn(Column, Collection)</code> but better to read
+     * Convenience method to AND a verbatim sql condition to this Criteria.
+     * Equivalent to
+     * <code>#andNotIn(String, String[])</code> but better to read
      * if this is the first condition to be added to the Criteria.
+     * This is used as follows:
+     * <p>
+     * <code>
+     * Criteria criteria = new Criteria();
+     * criteria.whereVerbatimSql("count(foo.x) = ?", new Object[] {0});
+     * </code>
      *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
+     * @param sql the verbatim SQL to use.
+     * @param replacements the replacements for the "?" placeholders in SQL.
+     *
+     * @return the modified Criteria.
      */
-    public Criteria whereNotIn(Column column, Collection<?> values)
+    public Criteria whereVerbatimSql(String sql, Object[] replacements)
     {
-        return andNotIn(column, values);
+        Criterion criterion
+                = new Criterion(null, null, null, sql, replacements);
+        and(criterion);
+        return this;
     }
 
     /**
-     * Convenience method to AND a "not in" comparison with the conditions
-     * in this Criteria. Equivalent to
-     * <code>#andNotIn(String, Collection)</code> but better to read
-     * if this is the first condition to be added to the Criteria.
-     *
-     * @param column The column to run the comparison on
-     * @param values The values to compare against.
-     * @return A modified Criteria object.
-     */
-    public Criteria whereNotIn(String column, Collection<?> values)
-    {
-        return andNotIn(new ColumnImpl(column), values);
+     * Convenience method to AND a verbatim sql condition to this Criteria.
+     * Equivalent to
+     * <code>#andNotIn(String, String[], Column, Column)</code> but better
+     * to read if this is the first condition to be added to the Criteria.
+     * This is used as follows:
+     * <p>
+     * <code>
+     * Criteria criteria = new Criteria();
+     * criteria.whereVerbatimSql(
+     *     "count(foo.x) = ?",
+     *     new Object[] {0},
+     *     FooPeer.X,
+     *     null);
+     * </code>
+     *
+     * @param sql the verbatim SQL to use.
+     * @param replacements the replacements for the "?" placeholders in SQL.
+     * @param toAddToFromClause1 a column to add to from clause, may be null.
+     * @param toAddToFromClause2 a column to add to from clause, may be null.
+     *
+     * @return the modified Criteria.
+     */
+    public Criteria whereVerbatimSql(
+            String sql,
+            Object[] replacements,
+            Column toAddToFromClause1,
+            Column toAddToFromClause2)
+    {
+        Criterion criterion = new Criterion(
+                toAddToFromClause1,
+                toAddToFromClause2,
+                null,
+                sql,
+                replacements);
+        and(criterion);
+        return this;
     }
 }



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


Mime
View raw message