You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2011/11/26 11:59:52 UTC

svn commit: r1206426 [3/7] - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/ torque-runtime/src/main/java/org/apache/torque/avalon/ torque-runtime/src/main/java/org/apache/torque/dsfactory/ torque-runtime/src/main/java/org/...

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java?rev=1206426&r1=1206425&r2=1206426&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java Sat Nov 26 10:59:15 2011
@@ -36,9 +36,12 @@ import java.util.Set;
 import org.apache.commons.lang.ObjectUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.torque.Column;
+import org.apache.torque.ColumnImpl;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.om.ObjectKey;
+import org.apache.torque.sql.OrderBy;
 
 /**
  * Encapsulates conditions to access rows in database tables.
@@ -111,12 +114,6 @@ public class Criteria implements Seriali
     /** Comparison type. */
     public static final SqlEnum JOIN = SqlEnum.JOIN;
 
-    /** "Order by" qualifier - ascending */
-    private static final SqlEnum ASC = SqlEnum.ASC;
-
-    /** "Order by" qualifier - descending */
-    private static final SqlEnum DESC = SqlEnum.DESC;
-
     /** "IS NULL" null comparison */
     public static final SqlEnum ISNULL = SqlEnum.ISNULL;
 
@@ -148,28 +145,27 @@ public class Criteria implements Seriali
     private UniqueList<String> selectModifiers = new UniqueList<String>();
 
     /** List of all columns to select. */
-    private UniqueList<String> selectColumns = new UniqueList<String>();
+    private UniqueColumnList selectColumns = new UniqueColumnList();
 
     /** All "order by" clauses, containing the order ASC or DESC. */
-    private UniqueList<String> orderByColumns = new UniqueList<String>();
+    private UniqueList<OrderBy> orderByColumns = new UniqueList<OrderBy>();
 
-    /** The names of columns to add to a groupoBy clause */
-    private UniqueList<String> groupByColumns = new UniqueList<String>();
+    /** The names of columns to add to a groupBy clause */
+    private UniqueColumnList groupByColumns = new UniqueColumnList();
 
     /** The having clause in a query. */
     private Criterion having = null;
 
-    /** The criterion objects, keyed by the column name. */
-    private Map<String, Criteria.Criterion> criterionMap
-            = new HashMap<String, Criteria.Criterion>();
+    /** The criterion objects, keyed by the column. */
+    private Map<Column, Criteria.Criterion> criterionMap
+            = new HashMap<Column, Criteria.Criterion>();
 
     /**
      * Maps column alias names to the real column names.
-     * The key of the map is the alias and the value is the real name
-     * of the column.
+     * The key of the map is the alias and the value is the real column.
      */
-    private Map<String, String> asColumns
-            = new LinkedHashMap<String, String>();
+    private Map<String, Column> asColumns
+            = new LinkedHashMap<String, Column>();
 
     /** Contains all joins. */
     private List<Join> joins = new ArrayList<Join>();
@@ -281,26 +277,49 @@ public class Criteria implements Seriali
      *
      * </code>
      *
-     * @param name  wanted Name of the column
+     * @param name wanted Name of the column
      * @param clause SQL clause to select from the table
      *
      * If the name already exists, it is replaced by the new clause.
      *
      * @return A modified Criteria object.
      */
-    public Criteria addAsColumn(String name, String clause)
+    public Criteria addAsColumn(String name, Column clause)
     {
         asColumns.put(name, clause);
         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>
+     *
+     * @param name wanted Name of the column
+     * @param clause SQL clause to select from the table
+     *
+     * If the name already exists, it is replaced by the new clause.
+     *
+     * @return A modified Criteria object.
+     */
+    public Criteria addAsColumn(String name, String clause)
+    {
+        asColumns.put(name, new ColumnImpl(clause));
+        return this;
+    }
+
+    /**
      * Get the column aliases.
      *
      * @return A Map which map the column alias names
      * to the alias clauses.
      */
-    public Map<String, String> getAsColumns()
+    public Map<String, Column> getAsColumns()
     {
         return asColumns;
     }
@@ -351,34 +370,30 @@ public class Criteria implements Seriali
      */
     public boolean containsKey(String table, String column)
     {
-        return criterionMap.containsKey(table + '.' + column);
+        return containsTopLevelColumn(new ColumnImpl(table, column));
     }
 
     /**
-     * Convenience method to return value as a boolean.
+     * Checks whether a Criteria contains a column with the given column's
+     * SQL expression a a top level Criterion.
      *
-     * @param column String name of column.
-     * @return A boolean.
-     */
-    public boolean getBoolean(String column)
-    {
-        return ((Boolean) getCriterion(column).getValue()).booleanValue();
-    }
-
-    /**
-     * Convenience method to return value as a boolean.
+     * @param column the column to check, not null.
      *
-     * @param table String name of table.
-     * @param column String name of column.
-     * @return A boolean.
+     * @return true if a top-level criterion with the same column sql expression
+     *         is contained, false otherwise.
      */
-    public boolean getBoolean(String table, String column)
+    private boolean containsTopLevelColumn(Column column)
     {
-        return getBoolean(new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        for (Column candidate : criterionMap.keySet())
+        {
+            if (candidate.getSqlExpression().equals(
+                    column.getSqlExpression()))
+            {
+                return true;
+            }
+        }
+        return false;
     }
-
     /**
      * Will force the sql represented by this criteria to be executed within
      * a transaction.  This is here primarily to support the oid type in
@@ -402,14 +417,34 @@ public class Criteria implements Seriali
     }
 
     /**
-     * Method to return criteria related to columns in a table.
+     * Return the criterion for a column.
      *
-     * @param column String name of column.
+     * @param column the column to get the criterion for.
+     * @return the Criterion, or null if no criterion is defined
+     *         for this column.
+     */
+    public Criterion getCriterion(Column column)
+    {
+        for (Map.Entry<Column, Criterion> mapEntry : criterionMap.entrySet())
+        {
+            if (mapEntry.getKey().getSqlExpression().equals(
+                    column.getSqlExpression()))
+            {
+                return mapEntry.getValue();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Method to return criteria related to a column in a table.
+     *
+     * @param column the column to get the criterion for.
      * @return A Criterion.
      */
     public Criterion getCriterion(String column)
     {
-        return criterionMap.get(column);
+        return getCriterion(new ColumnImpl(column));
     }
 
     /**
@@ -421,10 +456,7 @@ public class Criteria implements Seriali
      */
     public Criterion getCriterion(String table, String column)
     {
-        return getCriterion(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getCriterion(new ColumnImpl(table, column));
     }
 
     /**
@@ -435,7 +467,7 @@ public class Criteria implements Seriali
      * @param column String full name of column (for example TABLE.COLUMN).
      * @return A Criterion.
      */
-    public Criterion getNewCriterion(String column, Object value,
+    public Criterion getNewCriterion(Column column, Object value,
             SqlEnum comparison)
     {
         return new Criterion(column, value, comparison);
@@ -476,28 +508,17 @@ public class Criteria implements Seriali
      */
     public Criteria add(Criterion c)
     {
-        criterionMap.put(c.getFullyQualifiedColumnName(), c);
+        criterionMap.put(c.getColumn(), c);
         return this;
     }
 
     /**
-     * Method to return a String table name.
-     *
-     * @param name A String with the name of the key.
-     * @return A String with the value of the object at key.
-     */
-    public String getColumnName(String name)
-    {
-        return getCriterion(name).getColumn();
-    }
-
-    /**
      * Method to return a comparison String.
      *
      * @param key String name of the key.
      * @return A String with the value of the object at key.
      */
-    public SqlEnum getComparison(String key)
+    public SqlEnum getComparison(Column key)
     {
         return getCriterion(key).getComparison();
     }
@@ -511,69 +532,89 @@ public class Criteria implements Seriali
      */
     public SqlEnum getComparison(String table, String column)
     {
-        return getComparison(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getComparison(new ColumnImpl(table, column));
     }
 
     /**
-     * Convenience method to return a Date.
+     * Get the Database(Map) name.
      *
-     * @param name column name (TABLE.COLUMN)
-     * @return A java.util.Date with the value of object at key.
+     * @return A String with the Database(Map) name.  By default, this
+     * is PoolBrokerService.DEFAULT.
      */
-    public java.util.Date getDate(String name)
+    public String getDbName()
     {
-        return (java.util.Date) getCriterion(name).getValue();
+        return dbName;
     }
 
     /**
-     * Convenience method to return a Date.
+     * Set the DatabaseMap name.  If <code>null</code> is supplied, uses value
+     * provided by <code>Torque.getDefaultDB()</code>.
+     *
+     * @param dbName A String with the Database(Map) name.
+     */
+    public void setDbName(String dbName)
+    {
+        this.dbName = (dbName == null ? Torque.getDefaultDB() : dbName.trim());
+    }
+
+    /**
+     * Convenience method to return value as a boolean.
+     *
+     * @param column The column to retrieve the value for.
+     *
+     * @return A boolean.
+     */
+    public boolean getBoolean(Column column)
+    {
+        return ((Boolean) getCriterion(column).getValue()).booleanValue();
+    }
+
+    /**
+     * Convenience method to return value as a boolean.
      *
      * @param table String name of table.
      * @param column String name of column.
-     * @return A java.util.Date with the value of object at key.
+     * @return A boolean.
      */
-    public java.util.Date getDate(String table, String column)
+    public boolean getBoolean(String table, String column)
     {
-        return getDate(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getBoolean(new ColumnImpl(table, column));
     }
 
     /**
-     * Get the Database(Map) name.
+     * Convenience method to return a Date.
      *
-     * @return A String with the Database(Map) name.  By default, this
-     * is PoolBrokerService.DEFAULT.
+     * @param column The column to retrieve the value for.
+     *
+     * @return A java.util.Date with the value of object at key.
      */
-    public String getDbName()
+    public java.util.Date getDate(Column column)
     {
-        return dbName;
+        return (java.util.Date) getCriterion(column).getValue();
     }
 
     /**
-     * Set the DatabaseMap name.  If <code>null</code> is supplied, uses value
-     * provided by <code>Torque.getDefaultDB()</code>.
+     * Convenience method to return a Date.
      *
-     * @param dbName A String with the Database(Map) name.
+     * @param table String name of table.
+     * @param column String name of column.
+     * @return A java.util.Date with the value of object at key.
      */
-    public void setDbName(String dbName)
+    public java.util.Date getDate(String table, String column)
     {
-        this.dbName = (dbName == null ? Torque.getDefaultDB() : dbName.trim());
+        return getDate(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return a double.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return A double with the value of object at key.
      */
-    public double getDouble(String name)
+    public double getDouble(Column column)
     {
-        Object obj = getCriterion(name).getValue();
+        Object obj = getCriterion(column).getValue();
         if (obj instanceof String)
         {
             return new Double((String) obj).doubleValue();
@@ -590,20 +631,19 @@ public class Criteria implements Seriali
      */
     public double getDouble(String table, String column)
     {
-        return getDouble(new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getDouble(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return a float.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return A float with the value of object at key.
      */
-    public float getFloat(String name)
+    public float getFloat(Column column)
     {
-        Object obj = getCriterion(name).getValue();
+        Object obj = getCriterion(column).getValue();
         if (obj instanceof String)
         {
             return new Float((String) obj).floatValue();
@@ -620,20 +660,19 @@ public class Criteria implements Seriali
      */
     public float getFloat(String table, String column)
     {
-        return getFloat(new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getFloat(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return an Integer.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return An Integer with the value of object at key.
      */
-    public Integer getInteger(String name)
+    public Integer getInteger(Column column)
     {
-        Object obj = getCriterion(name).getValue();
+        Object obj = getCriterion(column).getValue();
         if (obj instanceof String)
         {
             return new Integer((String) obj);
@@ -650,21 +689,19 @@ public class Criteria implements Seriali
      */
     public Integer getInteger(String table, String column)
     {
-        return getInteger(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getInteger(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return an int.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return An int with the value of object at key.
      */
-    public int getInt(String name)
+    public int getInt(Column column)
     {
-        Object obj = getCriterion(name).getValue();
+        Object obj = getCriterion(column).getValue();
         if (obj instanceof String)
         {
             return new Integer((String) obj).intValue();
@@ -681,21 +718,19 @@ public class Criteria implements Seriali
      */
     public int getInt(String table, String column)
     {
-        return getInt(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getInt(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return a BigDecimal.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return A BigDecimal with the value of object at key.
      */
-    public BigDecimal getBigDecimal(String name)
+    public BigDecimal getBigDecimal(Column column)
     {
-        Object obj = getCriterion(name).getValue();
+        Object obj = getCriterion(column).getValue();
         if (obj instanceof String)
         {
             return new BigDecimal((String) obj);
@@ -712,21 +747,19 @@ public class Criteria implements Seriali
      */
     public BigDecimal getBigDecimal(String table, String column)
     {
-        return getBigDecimal(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getBigDecimal(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return a long.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return A long with the value of object at key.
      */
-    public long getLong(String name)
+    public long getLong(Column column)
     {
-        Object obj = getCriterion(name).getValue();
+        Object obj = getCriterion(column).getValue();
         if (obj instanceof String)
         {
             return new Long((String) obj).longValue();
@@ -743,21 +776,19 @@ public class Criteria implements Seriali
      */
     public long getLong(String table, String column)
     {
-        return getLong(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getLong(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return a String.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return A String with the value of object at key.
      */
-    public String getString(String name)
+    public String getString(Column column)
     {
-        return (String) getCriterion(name).getValue();
+        return (String) getCriterion(column).getValue();
     }
 
     /**
@@ -769,34 +800,20 @@ public class Criteria implements Seriali
      */
     public String getString(String table, String column)
     {
-        return getString(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
-    }
-
-    /**
-     * Method to return a String table name.
-     *
-     * @param name A String with the name of the key.
-     * @return A String with the value of object at key.
-     */
-    public String getTableName(String name)
-    {
-        return getCriterion(name).getTable();
+        return getString(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return a List.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
      *
      * @return A List with the value of object at key.
      */
     @SuppressWarnings("unchecked")
-    public List<Object> getList(String name)
+    public List<Object> getList(Column column)
     {
-        return (List<Object>) getCriterion(name).getValue();
+        return (List<Object>) getCriterion(column).getValue();
     }
 
     /**
@@ -808,21 +825,19 @@ public class Criteria implements Seriali
      */
     public List<Object> getList(String table, String column)
     {
-        return getList(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getList(new ColumnImpl(table, column));
     }
 
     /**
      * Method to return the value that was added to Criteria.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return An Object with the value of object at key.
      */
-    public Object getValue(String name)
+    public Object getValue(Column column)
     {
-        return getCriterion(name).getValue();
+        return getCriterion(column).getValue();
     }
 
     /**
@@ -834,21 +849,19 @@ public class Criteria implements Seriali
      */
     public Object getValue(String table, String column)
     {
-        return getValue(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getValue(new ColumnImpl(table, column));
     }
 
     /**
      * Convenience method to return an ObjectKey.
      *
-     * @param name A String with the name of the key.
+     * @param column The column to retrieve the value for.
+     *
      * @return An ObjectKey with the value of object at key.
      */
-    public ObjectKey getObjectKey(String name)
+    public ObjectKey getObjectKey(Column column)
     {
-        return (ObjectKey) getCriterion(name).getValue();
+        return (ObjectKey) getCriterion(column).getValue();
     }
 
     /**
@@ -860,10 +873,7 @@ public class Criteria implements Seriali
      */
     public ObjectKey getObjectKey(String table, String column)
     {
-        return getObjectKey(
-                new StringBuffer(table.length() + column.length() + 1)
-                .append(table).append('.').append(column)
-                .toString());
+        return getObjectKey(new ColumnImpl(table, column));
     }
 
     /**
@@ -877,7 +887,7 @@ public class Criteria implements Seriali
      *
      * @deprecated this method only works if a criterion exists for the key.
      */
-    public Object get(String key)
+    public Object get(Column key)
     {
         return getValue(key);
     }
@@ -918,7 +928,7 @@ public class Criteria implements Seriali
     /**
      * Equivalent to add(key, value).
      *
-     * @param key the column name
+     * @param column the column.
      * @param value An Object to which the column should be equal.
      *
      * @return Instance of self.
@@ -927,9 +937,9 @@ public class Criteria implements Seriali
      *
      * @deprecated use add(String, Object) instead
      */
-    public Object put(String key, Object value)
+    public Object put(Column column, Object value)
     {
-        return add(key, value);
+        return add(column, value);
     }
 
     /**
@@ -939,12 +949,12 @@ public class Criteria implements Seriali
      *
      * @param t Objects to be stored in this criteria.
      */
-    public synchronized void putAll(Map<String, Criterion> t)
+    public synchronized void putAll(Map<Column, Criterion> t)
     {
-        Iterator<Map.Entry<String, Criterion>> i = t.entrySet().iterator();
+        Iterator<Map.Entry<Column, Criterion>> i = t.entrySet().iterator();
         while (i.hasNext())
         {
-            Map.Entry<String, Criterion> e = i.next();
+            Map.Entry<Column, Criterion> e = i.next();
             Criterion val = e.getValue();
             criterionMap.put(e.getKey(), val);
         }
@@ -972,6 +982,64 @@ public class Criteria implements Seriali
      *
      * @return A modified Criteria object.
      */
+    public Criteria add(Column column, Object value)
+    {
+        add(column, value, EQUAL);
+        return this;
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias.
+     * If a criterion for the requested column already exists, it is
+     * replaced. If is used as follow:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().add(&quot;column&quot;,
+     *                                      &quot;value&quot;
+     *                                      Criteria.GREATER_THAN);
+     * </code>
+     *
+     * Any comparison can be used.
+     *
+     * The name of the table must be used implicitly in the column name,
+     * so the Column name must be something like 'TABLE.id'. If you
+     * don't like this, you can use the add(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison A String.
+     *
+     * @return A modified Criteria object.
+     */
+    public Criteria add(Column column, Object value, SqlEnum comparison)
+    {
+        criterionMap.put(column, new Criterion(column, value, comparison));
+        return this;
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias. If a
+     * criterion for the requested column already exists, it is
+     * replaced. This 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.
+     *
+     * The name of the table must be used implicitly in the column name,
+     * so the Column name must be something like 'TABLE.id'. If you
+     * don't like this, you can use the add(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     *
+     * @return A modified Criteria object.
+     */
     public Criteria add(String column, Object value)
     {
         add(column, value, EQUAL);
@@ -1004,7 +1072,10 @@ public class Criteria implements Seriali
      */
     public Criteria add(String column, Object value, SqlEnum comparison)
     {
-        criterionMap.put(column, new Criterion(column, value, comparison));
+        Column columnImpl = new ColumnImpl(column);
+        criterionMap.put(
+                columnImpl,
+                new Criterion(columnImpl, value, comparison));
         return this;
     }
 
@@ -1061,8 +1132,9 @@ public class Criteria implements Seriali
             Object value,
             SqlEnum comparison)
     {
-        criterionMap.put(table + '.' + column,
-                new Criterion(table, column, value, comparison));
+        Column columnImpl = new ColumnImpl(table, column);
+        criterionMap.put(columnImpl,
+                new Criterion(columnImpl, value, comparison));
         return this;
     }
 
@@ -1080,7 +1152,7 @@ public class Criteria implements Seriali
      *
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, boolean value)
+    public Criteria add(Column column, boolean value)
     {
         add(column, (value ? Boolean.TRUE : Boolean.FALSE));
         return this;
@@ -1101,7 +1173,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, boolean value, SqlEnum comparison)
+    public Criteria add(Column column, boolean value, SqlEnum comparison)
     {
         add(column, new Boolean(value), comparison);
         return this;
@@ -1120,7 +1192,7 @@ public class Criteria implements Seriali
      * @param value An int.
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, int value)
+    public Criteria add(Column column, int value)
     {
         add(column, new Integer(value));
         return this;
@@ -1141,7 +1213,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, int value, SqlEnum comparison)
+    public Criteria add(Column column, int value, SqlEnum comparison)
     {
         add(column, new Integer(value), comparison);
         return this;
@@ -1160,7 +1232,7 @@ public class Criteria implements Seriali
      * @param value A long.
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, long value)
+    public Criteria add(Column column, long value)
     {
         add(column, new Long(value));
         return this;
@@ -1181,7 +1253,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, long value, SqlEnum comparison)
+    public Criteria add(Column column, long value, SqlEnum comparison)
     {
         add(column, new Long(value), comparison);
         return this;
@@ -1200,7 +1272,7 @@ public class Criteria implements Seriali
      * @param value A float.
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, float value)
+    public Criteria add(Column column, float value)
     {
         add(column, new Float(value));
         return this;
@@ -1221,7 +1293,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, float value, SqlEnum comparison)
+    public Criteria add(Column column, float value, SqlEnum comparison)
     {
         add(column, new Float(value), comparison);
         return this;
@@ -1240,7 +1312,7 @@ public class Criteria implements Seriali
      * @param value A double.
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, double value)
+    public Criteria add(Column column, double value)
     {
         add(column, new Double(value));
         return this;
@@ -1261,7 +1333,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria add(String column, double value, SqlEnum comparison)
+    public Criteria add(Column column, double value, SqlEnum comparison)
     {
         add(column, new Double(value), comparison);
         return this;
@@ -1284,6 +1356,56 @@ public class Criteria implements Seriali
      * @param day An int with the day.
      * @return A modified Criteria object.
      */
+    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,date), 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 date An int with the date.
+     * @param comparison String describing how to compare the column with
+     *        the value
+     * @return A modified Criteria object.
+     */
+    public Criteria addDate(Column column, int year, int month, int date,
+            SqlEnum comparison)
+    {
+        add(column, new GregorianCalendar(year, month, date).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,date), EQUAL);
+     * </code>
+     *
+     * @param column A String value to use as column.
+     * @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.
+     */
     public Criteria addDate(String column, int year, int month, int day)
     {
         add(column, new GregorianCalendar(year, month, day).getTime());
@@ -1332,7 +1454,7 @@ public class Criteria implements Seriali
      * @param right A String with the right side of the join.
      * @return A modified Criteria object.
      */
-    public Criteria addJoin(String left, String right)
+    public Criteria addJoin(Column left, Column right)
     {
         return addJoin(left, right, null);
     }
@@ -1355,7 +1477,7 @@ public class Criteria implements Seriali
      *        Criteria.LEFT_JOIN, Criteria.RIGHT_JOIN, Criteria.INNER_JOIN
      * @return A modified Criteria object.
      */
-    public Criteria addJoin(String left, String right, SqlEnum operator)
+    public Criteria addJoin(Column left, Column right, SqlEnum operator)
     {
         joins.add(new Join(left, right, operator));
 
@@ -1363,25 +1485,97 @@ public class Criteria implements Seriali
     }
 
     /**
-     * get the List of Joins.  This method is meant to
-     * be called by BasePeer.
-     * @return a List which contains objects of type Join.
-     *         If the criteria does not contains any joins, the list is empty
-     */
-    public List<Join> getJoins()
-    {
-        return joins;
-    }
-
-    /**
-     * Adds an 'IN' clause with the criteria supplied as an Object
-     * array.  For example:
+     * This is the way that you should add a join of two tables.  For
+     * example:
      *
      * <p>
-     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * AND PROJECT.PROJECT_ID=FOO.PROJECT_ID
      * <p>
      *
-     * where 'values' contains three objects that evaluate to the
+     * left = PROJECT.PROJECT_ID
+     * right = FOO.PROJECT_ID
+     *
+     * @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);
+    }
+
+    /**
+     * This is the way that you should add a join of two tables.  For
+     * example:
+     *
+     * <p>
+     * PROJECT LEFT JOIN FOO ON PROJECT.PROJECT_ID=FOO.PROJECT_ID
+     * <p>
+     *
+     * left = &quot;PROJECT.PROJECT_ID&quot;
+     * right = &quot;FOO.PROJECT_ID&quot;
+     * operator = Criteria.LEFT_JOIN
+     *
+     * @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.  This method is meant to
+     * be called by BasePeer.
+     * @return a List which contains objects of type Join.
+     *         If the criteria does not contains any joins, the list is empty
+     */
+    public List<Join> getJoins()
+    {
+        return joins;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as an Object
+     * array.  For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * replaced.
+     *
+     * @param column The column to run the comparison on
+     * @param values An Object[] with the allowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria addIn(Column column, Object[] values)
+    {
+        add(column, values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as an Object
+     * array.  For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
      * respective strings above when .toString() is called.
      *
      * If a criterion for the requested column already exists, it is
@@ -1393,7 +1587,7 @@ public class Criteria implements Seriali
      */
     public Criteria addIn(String column, Object[] values)
     {
-        add(column, (Object) values, Criteria.IN);
+        add(column, values, Criteria.IN);
         return this;
     }
 
@@ -1414,9 +1608,33 @@ public class Criteria implements Seriali
      * @param values An int[] with the allowed values.
      * @return A modified Criteria object.
      */
-    public Criteria addIn(String column, int[] values)
+    public Criteria addIn(Column column, int[] values)
     {
-        add(column, (Object) values, Criteria.IN);
+        add(column, values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a Collection.
+     * For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
+     *
+     * If a criterion for the requested column already exists, it is
+     * replaced.
+     *
+     * @param column The column to run the comparison on
+     * @param values A Collection with the allowed values.
+     *
+     * @return A modified Criteria object.
+     */
+    public Criteria addIn(Column column, Collection<?> values)
+    {
+        add(column, values, Criteria.IN);
         return this;
     }
 
@@ -1440,7 +1658,31 @@ public class Criteria implements Seriali
      */
     public Criteria addIn(String column, Collection<?> values)
     {
-        add(column, (Object) values, Criteria.IN);
+        add(column, values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as an Object
+     * array.  For example:
+     *
+     * <p>
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * replaced.
+     *
+     * @param column The column to run the comparison on
+     * @param values An Object[] with the disallowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria addNotIn(Column column, Object[] values)
+    {
+        add(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -1464,7 +1706,7 @@ public class Criteria implements Seriali
      */
     public Criteria addNotIn(String column, Object[] values)
     {
-        add(column, (Object) values, Criteria.NOT_IN);
+        add(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -1485,9 +1727,33 @@ public class Criteria implements Seriali
      * @param values An int[] with the disallowed values.
      * @return A modified Criteria object.
      */
-    public Criteria addNotIn(String column, int[] values)
+    public Criteria addNotIn(Column column, int[] values)
+    {
+        add(column, values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as a Collection.
+     * For example:
+     *
+     * <p>
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three Strings "FOO", "BAR" and "ZOW".
+     *
+     * If a criterion for the requested column already exists, it is
+     * replaced.
+     *
+     * @param column The column to run the comparison on
+     * @param values A Collection with the disallowed values.
+     *
+     * @return A modified Criteria object.
+     */
+    public Criteria addNotIn(Column column, Collection<?> values)
     {
-        add(column, (Object) values, Criteria.NOT_IN);
+        add(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -1511,7 +1777,7 @@ public class Criteria implements Seriali
      */
     public Criteria addNotIn(String column, Collection<?> values)
     {
-        add(column, (Object) values, Criteria.NOT_IN);
+        add(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -1629,12 +1895,24 @@ public class Criteria implements Seriali
     /**
      * Add select column.
      *
-     * @param name A String with the name of the select column.
+     * @param column The select column to add.
+     * @return A modified Criteria object.
+     */
+    public Criteria addSelectColumn(Column column)
+    {
+        selectColumns.add(column);
+        return this;
+    }
+
+    /**
+     * Add select column.
+     *
+     * @param column A String with the name of the select column.
      * @return A modified Criteria object.
      */
-    public Criteria addSelectColumn(String name)
+    public Criteria addSelectColumn(String column)
     {
-        selectColumns.add(name);
+        selectColumns.add(new ColumnImpl(column));
         return this;
     }
 
@@ -1643,7 +1921,7 @@ public class Criteria implements Seriali
      *
      * @return An List with the names of the select columns.
      */
-    public UniqueList<String> getSelectColumns()
+    public UniqueColumnList getSelectColumns()
     {
         return selectColumns;
     }
@@ -1664,42 +1942,80 @@ public class Criteria implements Seriali
      * @param groupBy The name of the column to group by.
      * @return A modified Criteria object.
      */
-    public Criteria addGroupByColumn(String groupBy)
+    public Criteria addGroupByColumn(Column groupBy)
     {
         groupByColumns.add(groupBy);
         return this;
     }
 
     /**
+     * Add group by column name.
+     *
+     * @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;
+    }
+
+    /**
      * Add order by column name, explicitly specifying ascending.
      *
-     * @param name The name of the column to order by.
+     * @param column The column to order by.
      * @return A modified Criteria object.
      */
-    public Criteria addAscendingOrderByColumn(String name)
+    public Criteria addAscendingOrderByColumn(Column column)
     {
-        orderByColumns.add(name + ' ' + ASC);
+        orderByColumns.add(new OrderBy(column, SqlEnum.ASC, false));
+        return this;
+    }
+
+    /**
+     * Add order by column name, explicitly specifying ascending.
+     *
+     * @param column 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 order by column name, explicitly specifying descending.
      *
-     * @param name The name of the column to order by.
+     * @param column The column to order by.
      * @return A modified Criteria object.
      */
-    public Criteria addDescendingOrderByColumn(String name)
+    public Criteria addDescendingOrderByColumn(Column column)
     {
-        orderByColumns.add(name + ' ' + DESC);
+        orderByColumns.add(new OrderBy(column, SqlEnum.DESC, false));
+        return this;
+    }
+
+    /**
+     * Add order by column name, explicitly specifying descending.
+     *
+     * @param column The column to order by.
+     * @return A modified Criteria object.
+     */
+    public Criteria addDescendingOrderByColumn(String column)
+    {
+        orderByColumns.add(
+                new OrderBy(new ColumnImpl(column), SqlEnum.DESC, false));
         return this;
     }
 
     /**
      * Get order by columns.
      *
-     * @return An UniqueList with the name of the order columns.
+     * @return An UniqueList with the name of the order columns, not null.
      */
-    public UniqueList<String> getOrderByColumns()
+    public UniqueList<OrderBy> getOrderByColumns()
     {
         return orderByColumns;
     }
@@ -1707,9 +2023,9 @@ public class Criteria implements Seriali
     /**
      * Get group by columns.
      *
-     * @return An UniqueList with the name of the groupBy clause.
+     * @return An UniqueList with the name of the groupBy clause, not null.
      */
-    public UniqueList<String> getGroupByColumns()
+    public UniqueColumnList getGroupByColumns()
     {
         return groupByColumns;
     }
@@ -1725,19 +2041,26 @@ public class Criteria implements Seriali
     }
 
     /**
-     * Remove an object from the criteria.
+     * Remove all objects with the given key from the criteria.
      *
      * @param key A String with the key to be removed.
      * @return The value of the removed criterion, or null.
      */
-    public Object remove(String key)
+    public Object remove(Column key)
     {
-        Criterion removed = criterionMap.remove(key);
-        if (removed == null)
-        {
-            return null;
+        Iterator<Map.Entry<Column, Criterion>> entryIt
+                = criterionMap.entrySet().iterator();
+        while (entryIt.hasNext())
+        {
+            Map.Entry<Column, Criterion> entry = entryIt.next();
+            if (entry.getKey().getSqlExpression().equals(
+                    key.getSqlExpression()))
+            {
+                entryIt.remove();
+                return entry.getValue().getValue();
+            }
         }
-        return removed.getValue();
+        return null;
     }
 
     /**
@@ -1774,7 +2097,7 @@ public class Criteria implements Seriali
      *
      * @return all keys, not null.
      */
-    public Set<String> keySet()
+    public Set<Column> keySet()
     {
         return criterionMap.keySet();
     }
@@ -1823,10 +2146,10 @@ public class Criteria implements Seriali
         {
             return false;
         }
-        for (Iterator<?> it = criteria.keySet().iterator(); it.hasNext();)
+        for (Iterator<Column> it = criteria.keySet().iterator(); it.hasNext();)
         {
-            String key = (String) it.next();
-            if (criterionMap.containsKey(key))
+            Column key = it.next();
+            if (containsTopLevelColumn(key))
             {
                 Criterion a = this.getCriterion(key);
                 Criterion b = criteria.getCriterion(key);
@@ -1916,7 +2239,7 @@ public class Criteria implements Seriali
      */
     public Criteria and(Criterion c)
     {
-        Criterion oc = getCriterion(c.getFullyQualifiedColumnName());
+        Criterion oc = getCriterion(c.getColumn());
 
         if (oc == null)
         {
@@ -1951,7 +2274,7 @@ public class Criteria implements Seriali
      *
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, Object value)
+    public Criteria and(Column column, Object value)
     {
         and(column, value, EQUAL);
         return this;
@@ -1981,7 +2304,7 @@ public class Criteria implements Seriali
      *
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, Object value, SqlEnum comparison)
+    public Criteria and(Column column, Object value, SqlEnum comparison)
     {
         Criterion oc = getCriterion(column);
         Criterion nc = new Criterion(column, value, comparison);
@@ -1998,6 +2321,63 @@ public class Criteria implements Seriali
     }
 
     /**
+     * This method adds a new criterion to the list of criterias. If a
+     * criterion for the requested column already exists, it is
+     * &quot;AND&quot;ed to the existing criterion. This is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().and(&quot;column&quot;,
+     *                                      &quot;value&quot;);
+     * </code>
+     *
+     * An EQUAL comparison is used for column and value.
+     *
+     * The name of the table must be used implicitly in the column name,
+     * so the Column name must be something like 'TABLE.id'. If you
+     * don't like this, you can use the and(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     *
+     * @return A modified Criteria object.
+     */
+    public Criteria and(String column, Object value)
+    {
+        return and(column, value, EQUAL);
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias.
+     * If a criterion for the requested column already exists, it is
+     * &quot;AND&quot;ed to the existing criterion. If is used as follow:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().and(&quot;column&quot;,
+     *                                      &quot;value&quot;
+     *                                      Criteria.GREATER_THAN);
+     * </code>
+     *
+     * Any comparison can be used.
+     *
+     * The name of the table must be used implicitly in the column name,
+     * so the Column name must be something like 'TABLE.id'. If you
+     * don't like this, you can use the and(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison A String.
+     *
+     * @return A modified Criteria object.
+     */
+    public Criteria and(String column, Object value, SqlEnum comparison)
+    {
+        ColumnImpl columnImpl = new ColumnImpl(column);
+        return and(columnImpl, value, comparison);
+    }
+
+    /**
      * This method adds a new criterion to the list of criterias.
      * If a criterion for the requested column already exists, it is
      * &quot;AND&quot;ed to the existing criterion. If is used as follows:
@@ -2015,6 +2395,8 @@ public class Criteria implements Seriali
      * @param column The column to run the comparison on
      * @param value An Object.
      * @return A modified Criteria object.
+     *
+     * @deprecated use and(Column, Object) instead
      */
     public Criteria and(String table, String column, Object value)
     {
@@ -2043,6 +2425,8 @@ public class Criteria implements Seriali
      * @param comparison String describing how to compare the column with
      *        the value
      * @return A modified Criteria object.
+     *
+     * @deprecated use and(Column, Object, comparison) instead
      */
     public Criteria and(String table, String column, Object value,
             SqlEnum comparison)
@@ -2052,7 +2436,7 @@ public class Criteria implements Seriali
 
         if (oc == null)
         {
-            criterionMap.put(table + '.' + column, nc);
+            criterionMap.put(new ColumnImpl(table, column), nc);
         }
         else
         {
@@ -2074,7 +2458,7 @@ public class Criteria implements Seriali
      * @param value A Boolean.
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, boolean value)
+    public Criteria and(Column column, boolean value)
     {
         and(column, new Boolean(value));
         return this;
@@ -2095,7 +2479,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, boolean value, SqlEnum comparison)
+    public Criteria and(Column column, boolean value, SqlEnum comparison)
     {
         and(column, new Boolean(value), comparison);
         return this;
@@ -2114,7 +2498,7 @@ public class Criteria implements Seriali
      * @param value An int.
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, int value)
+    public Criteria and(Column column, int value)
     {
         and(column, new Integer(value));
         return this;
@@ -2134,7 +2518,7 @@ public class Criteria implements Seriali
      * @param comparison String describing how to compare the column with the value
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, int value, SqlEnum comparison)
+    public Criteria and(Column column, int value, SqlEnum comparison)
     {
         and(column, new Integer(value), comparison);
         return this;
@@ -2153,7 +2537,7 @@ public class Criteria implements Seriali
      * @param value A long.
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, long value)
+    public Criteria and(Column column, long value)
     {
         and(column, new Long(value));
         return this;
@@ -2174,7 +2558,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, long value, SqlEnum comparison)
+    public Criteria and(Column column, long value, SqlEnum comparison)
     {
         and(column, new Long(value), comparison);
         return this;
@@ -2193,7 +2577,7 @@ public class Criteria implements Seriali
      * @param value A float.
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, float value)
+    public Criteria and(Column column, float value)
     {
         and(column, new Float(value));
         return this;
@@ -2214,7 +2598,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, float value, SqlEnum comparison)
+    public Criteria and(Column column, float value, SqlEnum comparison)
     {
         and(column, new Float(value), comparison);
         return this;
@@ -2233,7 +2617,7 @@ public class Criteria implements Seriali
      * @param value A double.
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, double value)
+    public Criteria and(Column column, double value)
     {
         and(column, new Double(value));
         return this;
@@ -2254,7 +2638,7 @@ public class Criteria implements Seriali
      *        the value
      * @return A modified Criteria object.
      */
-    public Criteria and(String column, double value, SqlEnum comparison)
+    public Criteria and(Column column, double value, SqlEnum comparison)
     {
         and(column, new Double(value), comparison);
         return this;
@@ -2276,6 +2660,53 @@ public class Criteria implements Seriali
      * @param date An int with the date.
      * @return A modified Criteria object.
      */
+    public Criteria andDate(Column column, int year, int month, int date)
+    {
+        and(column, new GregorianCalendar(year, month, date).getTime());
+        return this;
+    }
+
+    /**
+     * Convenience method to add a Date object specified by
+     * year, month, and date into the Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new GregorianCalendar(year, month,date), 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.
+     * @param date An int with the date.
+     * @param comparison String describing how to compare the column with
+     *        the value
+     * @return A modified Criteria object.
+     */
+    public Criteria andDate(Column column, int year, int month, int date,
+            SqlEnum comparison)
+    {
+        and(column, new GregorianCalendar(year, month, date).getTime(), comparison);
+        return this;
+    }
+
+    /**
+     * Convenience method to add a Date object specified by
+     * year, month, and date into the Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new GregorianCalendar(year, month,date), EQUAL);
+     * </code>
+     *
+     * @param column A String value to use as column.
+     * @param year An int with the year.
+     * @param month An int with the month.
+     * @param date An int with the date.
+     * @return A modified Criteria object.
+     */
     public Criteria andDate(String column, int year, int month, int date)
     {
         and(column, new GregorianCalendar(year, month, date).getTime());
@@ -2325,13 +2756,36 @@ public class Criteria implements Seriali
      * @param values An Object[] with the allowed values.
      * @return A modified Criteria object.
      */
-    public Criteria andIn(String column, Object[] values)
+    public Criteria andIn(Column column, Object[] values)
     {
-        and(column, (Object) values, Criteria.IN);
+        and(column, values, Criteria.IN);
         return this;
     }
 
     /**
+     * Adds an 'IN' clause with the criteria supplied as an Object array.
+     * For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;AND&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values An Object[] with the allowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria andIn(String column, Object[] values)
+    {
+        return and(column, values, Criteria.IN);
+    }
+
+    /**
      * Adds an 'IN' clause with the criteria supplied as an int array.
      * For example:
      *
@@ -2348,9 +2802,33 @@ public class Criteria implements Seriali
      * @param values An int[] with the allowed values.
      * @return A modified Criteria object.
      */
-    public Criteria andIn(String column, int[] values)
+    public Criteria andIn(Column column, int[] values)
+    {
+        and(column, values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a List.
+     * For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;AND&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values A List with the allowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria andIn(Column column, List<?> values)
     {
-        and(column, (Object) values, Criteria.IN);
+        and(column, values, Criteria.IN);
         return this;
     }
 
@@ -2374,7 +2852,30 @@ public class Criteria implements Seriali
      */
     public Criteria andIn(String column, List<?> values)
     {
-        and(column, (Object) values, Criteria.IN);
+        return and(column, values, Criteria.IN);
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as an Object
+     * array.  For example:
+     *
+     * <p>
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;AND&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values An Object[] with the disallowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria andNotIn(Column column, Object[] values)
+    {
+        and(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -2396,32 +2897,56 @@ public class Criteria implements Seriali
      * @param values An Object[] with the disallowed values.
      * @return A modified Criteria object.
      */
-    public Criteria andNotIn(String column, Object[] values)
+    public Criteria andNotIn(String column, Object[] values)
+    {
+        ColumnImpl columnImpl = new ColumnImpl(column);
+        return and(columnImpl, values, Criteria.NOT_IN);
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as an int
+     * array.  For example:
+     *
+     * <p>
+     * FOO.ID NOT IN ('2', '3', '7')
+     * <p>
+     *
+     * where 'values' contains those three integers.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;AND&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values An int[] with the disallowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria andNotIn(Column column, int[] values)
     {
-        and(column, (Object) values, Criteria.NOT_IN);
+        and(column, values, Criteria.NOT_IN);
         return this;
     }
 
     /**
-     * Adds a 'NOT IN' clause with the criteria supplied as an int
-     * array.  For example:
+     * Adds a 'NOT IN' clause with the criteria supplied as a List.
+     * For example:
      *
      * <p>
-     * FOO.ID NOT IN ('2', '3', '7')
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
      * <p>
      *
-     * where 'values' contains those three integers.
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
      *
      * If a criterion for the requested column already exists, it is
      * &quot;AND&quot;ed to the existing criterion.
      *
      * @param column The column to run the comparison on
-     * @param values An int[] with the disallowed values.
+     * @param values A List with the disallowed values.
      * @return A modified Criteria object.
      */
-    public Criteria andNotIn(String column, int[] values)
+    public Criteria andNotIn(Column column, List<?> values)
     {
-        and(column, (Object) values, Criteria.NOT_IN);
+        and(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -2445,8 +2970,7 @@ public class Criteria implements Seriali
      */
     public Criteria andNotIn(String column, List<?> values)
     {
-        and(column, (Object) values, Criteria.NOT_IN);
-        return this;
+        return and(column, values, Criteria.NOT_IN);
     }
 
     /*
@@ -2476,7 +3000,7 @@ public class Criteria implements Seriali
      */
     public Criteria or(Criterion c)
     {
-        Criterion oc = getCriterion(c.getFullyQualifiedColumnName());
+        Criterion oc = getCriterion(c.getColumn());
 
         if (oc == null)
         {
@@ -2511,6 +3035,34 @@ public class Criteria implements Seriali
      *
      * @return A modified Criteria object.
      */
+    public Criteria or(Column column, Object value)
+    {
+        or(column, value, EQUAL);
+        return this;
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias. If a
+     * criterion for the requested column already exists, it is
+     * &quot;OR&quot;ed to the existing criterion. This is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().or(&quot;column&quot;,
+     *                                      &quot;value&quot;);
+     * </code>
+     *
+     * An EQUAL comparison is used for column and value.
+     *
+     * The name of the table must be used implicitly in the column name,
+     * so the Column name must be something like 'TABLE.id'. If you
+     * don't like this, you can use the or(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     *
+     * @return A modified Criteria object.
+     */
     public Criteria or(String column, Object value)
     {
         or(column, value, EQUAL);
@@ -2540,7 +3092,7 @@ public class Criteria implements Seriali
      * @param comparison A String.
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, Object value, SqlEnum comparison)
+    public Criteria or(Column column, Object value, SqlEnum comparison)
     {
         Criterion oc = getCriterion(column);
         Criterion nc = new Criterion(column, value, comparison);
@@ -2559,6 +3111,34 @@ public class Criteria implements Seriali
     /**
      * This method adds a new criterion to the list of criterias.
      * If a criterion for the requested column already exists, it is
+     * &quot;OR&quot;ed to the existing criterion. If is used as follow:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().or(&quot;column&quot;,
+     *                                      &quot;value&quot;
+     *                                      &quot;Criterion.GREATER_THAN&quot;);
+     * </code>
+     *
+     * Any comparison can be used.
+     *
+     * The name of the table must be used implicitly in the column name,
+     * so the Column name must be something like 'TABLE.id'. If you
+     * don't like this, you can use the or(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison A String.
+     * @return A modified Criteria object.
+     */
+    public Criteria or(String column, Object value, SqlEnum comparison)
+    {
+        return or(new ColumnImpl(column), value, comparison);
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias.
+     * If a criterion for the requested column already exists, it is
      * &quot;OR&quot;ed to the existing criterion. If is used as follows:
      *
      * <p>
@@ -2574,6 +3154,8 @@ public class Criteria implements Seriali
      * @param column The column to run the comparison on
      * @param value An Object.
      * @return A modified Criteria object.
+     *
+     * @deprecated use or(Column, Object) instead
      */
     public Criteria or(String table, String column, Object value)
     {
@@ -2601,6 +3183,8 @@ public class Criteria implements Seriali
      * @param value An Object.
      * @param comparison String describing how to compare the column with the value
      * @return A modified Criteria object.
+     *
+     * @deprecated use or(Column, Object, SqlEnum) instead
      */
     public Criteria or(String table, String column, Object value,
             SqlEnum comparison)
@@ -2609,7 +3193,7 @@ public class Criteria implements Seriali
         Criterion nc = new Criterion(table, column, value, comparison);
         if (oc == null)
         {
-            criterionMap.put(table + '.' + column, nc);
+            criterionMap.put(new ColumnImpl(table, column), nc);
         }
         else
         {
@@ -2631,7 +3215,7 @@ public class Criteria implements Seriali
      * @param value A Boolean.
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, boolean value)
+    public Criteria or(Column column, boolean value)
     {
         or(column, new Boolean(value));
         return this;
@@ -2652,7 +3236,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, boolean value, SqlEnum comparison)
+    public Criteria or(Column column, boolean value, SqlEnum comparison)
     {
         or(column, new Boolean(value), comparison);
         return this;
@@ -2672,7 +3256,7 @@ public class Criteria implements Seriali
      * @param value An int.
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, int value)
+    public Criteria or(Column column, int value)
     {
         or(column, new Integer(value));
         return this;
@@ -2694,7 +3278,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, int value, SqlEnum comparison)
+    public Criteria or(Column column, int value, SqlEnum comparison)
     {
         or(column, new Integer(value), comparison);
         return this;
@@ -2713,7 +3297,7 @@ public class Criteria implements Seriali
      * @param value A long.
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, long value)
+    public Criteria or(Column column, long value)
     {
         or(column, new Long(value));
         return this;
@@ -2734,7 +3318,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, long value, SqlEnum comparison)
+    public Criteria or(Column column, long value, SqlEnum comparison)
     {
         or(column, new Long(value), comparison);
         return this;
@@ -2753,7 +3337,7 @@ public class Criteria implements Seriali
      * @param value A float.
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, float value)
+    public Criteria or(Column column, float value)
     {
         or(column, new Float(value));
         return this;
@@ -2774,7 +3358,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, float value, SqlEnum comparison)
+    public Criteria or(Column column, float value, SqlEnum comparison)
     {
         or(column, new Float(value), comparison);
         return this;
@@ -2793,7 +3377,7 @@ public class Criteria implements Seriali
      * @param value A double.
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, double value)
+    public Criteria or(Column column, double value)
     {
         or(column, new Double(value));
         return this;
@@ -2814,7 +3398,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria or(String column, double value, SqlEnum comparison)
+    public Criteria or(Column column, double value, SqlEnum comparison)
     {
         or(column, new Double(value), comparison);
         return this;
@@ -2836,7 +3420,7 @@ public class Criteria implements Seriali
      * @param date An int with the date.
      * @return A modified Criteria object.
      */
-    public Criteria orDate(String column, int year, int month, int date)
+    public Criteria orDate(Column column, int year, int month, int date)
     {
         or(column, new GregorianCalendar(year, month, date));
         return this;
@@ -2849,6 +3433,27 @@ public class Criteria implements Seriali
      *
      * <p>
      * <code>
+     * or(column, new GregorianCalendar(year, month,date), EQUAL);
+     * </code>
+     *
+     * @param column A String value to use as column.
+     * @param year An int with the year.
+     * @param month An int with the month.
+     * @param date An int with the date.
+     * @return A modified Criteria object.
+     */
+    public Criteria orDate(String column, int year, int month, int date)
+    {
+        return or(column, new GregorianCalendar(year, month, date));
+    }
+
+    /**
+     * Convenience method to add a Date object specified by
+     * year, month, and date into the Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
      * or(column, new GregorianCalendar(year, month,date), comparison);
      * </code>
      *
@@ -2860,7 +3465,7 @@ public class Criteria implements Seriali
      * with the value
      * @return A modified Criteria object.
      */
-    public Criteria orDate(String column, int year, int month, int date,
+    public Criteria orDate(Column column, int year, int month, int date,
             SqlEnum comparison)
     {
         or(column, new GregorianCalendar(year, month, date), comparison);
@@ -2868,6 +3473,30 @@ public class Criteria implements Seriali
     }
 
     /**
+     * Convenience method to add a Date object specified by
+     * year, month, and date into the Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new GregorianCalendar(year, month,date), 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.
+     * @param date An int with the date.
+     * @param comparison String describing how to compare the column
+     * with the value
+     * @return A modified Criteria object.
+     */
+    public Criteria orDate(String column, int year, int month, int date,
+            SqlEnum comparison)
+    {
+        return or(column, new GregorianCalendar(year, month, date), comparison);
+    }
+
+    /**
      * Adds an 'IN' clause with the criteria supplied as an Object
      * array.  For example:
      *
@@ -2885,13 +3514,36 @@ public class Criteria implements Seriali
      * @param values An Object[] with the allowed values.
      * @return A modified Criteria object.
      */
-    public Criteria orIn(String column, Object[] values)
+    public Criteria orIn(Column column, Object[] values)
     {
-        or(column, (Object) values, Criteria.IN);
+        or(column, values, Criteria.IN);
         return this;
     }
 
     /**
+     * Adds an 'IN' clause with the criteria supplied as an Object
+     * array.  For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;OR&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values An Object[] with the allowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria orIn(String column, Object[] values)
+    {
+        return or(column, values, Criteria.IN);
+    }
+
+    /**
      * Adds an 'IN' clause with the criteria supplied as an int array.
      * For example:
      *
@@ -2908,9 +3560,33 @@ public class Criteria implements Seriali
      * @param values An int[] with the allowed values.
      * @return A modified Criteria object.
      */
-    public Criteria orIn(String column, int[] values)
+    public Criteria orIn(Column column, int[] values)
+    {
+        or(column, values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a List.
+     * For example:
+     *
+     * <p>
+     * FOO.NAME IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;OR&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values A List with the allowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria orIn(Column column, List<?> values)
     {
-        or(column, (Object) values, Criteria.IN);
+        or(column, values, Criteria.IN);
         return this;
     }
 
@@ -2934,7 +3610,30 @@ public class Criteria implements Seriali
      */
     public Criteria orIn(String column, List<?> values)
     {
-        or(column, (Object) values, Criteria.IN);
+        return or(column, values, Criteria.IN);
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as an Object
+     * array.  For example:
+     *
+     * <p>
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;OR&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values An Object[] with the disallowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria orNotIn(Column column, Object[] values)
+    {
+        or(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -2958,8 +3657,7 @@ public class Criteria implements Seriali
      */
     public Criteria orNotIn(String column, Object[] values)
     {
-        or(column, (Object) values, Criteria.NOT_IN);
-        return this;
+        return or(column, values, Criteria.NOT_IN);
     }
 
     /**
@@ -2979,9 +3677,9 @@ public class Criteria implements Seriali
      * @param values An int[] with the disallowed values.
      * @return A modified Criteria object.
      */
-    public Criteria orNotIn(String column, int[] values)
+    public Criteria orNotIn(Column column, int[] values)
     {
-        or(column, (Object) values, Criteria.NOT_IN);
+        or(column, values, Criteria.NOT_IN);
         return this;
     }
 
@@ -3003,13 +3701,36 @@ public class Criteria implements Seriali
      * @param values A List with the disallowed values.
      * @return A modified Criteria object.
      */
-    public Criteria orNotIn(String column, List<?> values)
+    public Criteria orNotIn(Column column, List<?> values)
     {
-        or(column, (Object) values, Criteria.NOT_IN);
+        or(column, values, Criteria.NOT_IN);
         return this;
     }
 
     /**
+     * Adds a 'NOT IN' clause with the criteria supplied as a List.
+     * For example:
+     *
+     * <p>
+     * FOO.NAME NOT IN ('FOO', 'BAR', 'ZOW')
+     * <p>
+     *
+     * where 'values' contains three objects that evaluate to the
+     * respective strings above when .toString() is called.
+     *
+     * If a criterion for the requested column already exists, it is
+     * &quot;OR&quot;ed to the existing criterion.
+     *
+     * @param column The column to run the comparison on
+     * @param values A List with the disallowed values.
+     * @return A modified Criteria object.
+     */
+    public Criteria orNotIn(String column, List<?> values)
+    {
+        return or(column, values, Criteria.NOT_IN);
+    }
+
+    /**
      * This is an inner class that describes an object in the criteria.
      */
     public final class Criterion implements Serializable
@@ -3029,11 +3750,8 @@ public class Criteria implements Seriali
         /** Comparison value. */
         private SqlEnum comparison;
 
-        /** Table name. */
-        private String table;
-
-        /** Column name. */
-        private String column;
+        /** Column. */
+        private Column column;
 
         /** flag to ignore case in comparision */
         private boolean ignoreStringCase = false;
@@ -3047,51 +3765,40 @@ public class Criteria implements Seriali
         private List<String> conjunctions = new ArrayList<String>();
 
         /**
-         * Creates a new instance, initializing a couple members.
-         */
-        private Criterion(Object val, SqlEnum comp)
-        {
-            this.value = val;
-            this.comparison = comp;
-        }
-
-        /**
          * Create a new instance.
          *
-         * @param table A String with the name of the table.
-         * @param column A String with the name of the column.
+         * @param table A String with the name of the table,
+         *        not null or blank.
+         * @param column A String with the name of the column,
+         *        not null or blank.
          * @param val An Object with the value for the Criteria.
          * @param comp A String with the comparison value.
+         *
+         * @throws NullPointerException if columnName or tableName are null.
+         * @throws IllegalArgumentException if columnName or tableName are
+         *         blank.
          */
         Criterion(String table, String column, Object val, SqlEnum comp)
         {
-            this(val, comp);
-            this.table = table;
-            this.column = (column == null ? "" : column);
+            this.value = val;
+            setComparison(comp);
+            this.column = new ColumnImpl(table, column);
         }
 
         /**
          * Create a new instance.
          *
-         * @param tableColumn A String with the full name of the
-         * column.
-         * @param val An Object with the value for the Criteria.
-         * @param comp A String with the comparison value.
+         * @param column the column description, not null.
+         * @param val An Object with the value for the Criteria, may be null.
+         * @param comp A String with the comparison value, not null.
+         *
+         * @throws NullPointerException if column is null.
          */
-        Criterion(String tableColumn, Object val, SqlEnum comp)
+        Criterion(Column column, Object val, SqlEnum comp)
         {
-            this(val, comp);
-            int dot = tableColumn.lastIndexOf('.');
-            if (dot == -1)
-            {
-                table = null;
-                column = tableColumn;
-            }
-            else
-            {
-                table = tableColumn.substring(0, dot);
-                column = tableColumn.substring(dot + 1);
-            }
+            this.value = val;
+            setComparison(comp);
+            setColumn(column);
         }
 
         /**
@@ -3109,65 +3816,55 @@ public class Criteria implements Seriali
         /**
          * Create a new instance.
          *
-         * @param tableColumn A String with the full name of the
-         * column.
+         * @param tableColumn the column description.
          * @param val An Object with the value for the Criteria.
          */
-        Criterion(String tableColumn, Object val)
+        Criterion(Column column, Object val)
         {
-            this(tableColumn, val, EQUAL);
+            this(column, val, EQUAL);
         }
 
         /**
-         * Get the column name.
+         * Sets the column.
          *
-         * @return A String with the column name.
-         */
-        public String getColumn()
-        {
-            return this.column;
-        }
-
-        /**
-         * Returns the fully qualified name of the criterion's column.
+         * @param column the column, not null.
          *
-         * @return the fully qualified column name.
+         * @throws NullPointerException if column is null.
          */
-        public String getFullyQualifiedColumnName()
+        private void setColumn(Column column)
         {
-            if (table == null)
+            if (column == null)
             {
-                return column;
+                throw new NullPointerException("column must not be null");
             }
-            return table + "." + column;
+            this.column = column;
         }
 
         /**
-         * Set the table name.
+         * Get the column.
          *
-         * @param name A String with the table name.
+         * @return the column.
          */
-        public void setTable(String name)
+        public Column getColumn()
         {
-            if ("".equals(name))
-            {
-                throw new IllegalArgumentException(
-                        "table name not be empty (use null instead)");
-            }
-            this.table = name;
+            return this.column;
         }
 
         /**
-         * Get the table name.
+         * Sets the comparison.
+         *
+         * @param comparison the comparison, not null.
          *
-         * @return A String with the table name, or null if the criteria
-         *         refers to an unqualified column.
+         * @throws NullPointerException if comparison is null.
          */
-        public String getTable()
+        private void setComparison(SqlEnum comparison)
         {
-            return this.table;
+            if (comparison == null)
+            {
+                throw new NullPointerException("comparison must not be null");
+            }
+            this.comparison = comparison;
         }
-
         /**
          * Get the comparison.
          *
@@ -3288,18 +3985,7 @@ public class Criteria implements Seriali
             }
             else
             {
-                String field = null;
-                if  (table == null)
-                {
-                    field = column;
-                }
-                else
-                {
-                    field = new StringBuilder(
-                            table.length() + 1 + column.length())
-                            .append(table).append('.').append(column)
-                            .toString();
-                }
+                String field = column.getSqlExpression();
                 sb.append(field).append(comparison).append(value);
             }
 
@@ -3357,10 +4043,8 @@ public class Criteria implements Seriali
 
             Criterion crit = (Criterion) obj;
 
-            boolean isEquiv = ((table == null && crit.getTable() == null)
-                    || (table != null && table.equals(crit.getTable()))
-                               )
-                    && column.equals(crit.getColumn())
+            boolean isEquiv = column.getSqlExpression().equals(
+                        crit.getColumn().getSqlExpression())
                     && comparison.equals(crit.getComparison());
 
             // we need to check for value equality
@@ -3387,7 +4071,7 @@ public class Criteria implements Seriali
             for (int i = 0; i < this.clauses.size(); i++)
             {
                 isEquiv &=  conjunctions.get(i)
-                        .equals((String) (crit.getConjunctions().get(i)));
+                        .equals((crit.getConjunctions().get(i)));
                 isEquiv &=  clauses.get(i)
                         .equals(crit.getClauses().get(i));
             }
@@ -3402,15 +4086,7 @@ public class Criteria implements Seriali
         {
             int h = value.hashCode() ^ comparison.hashCode();
 
-            if (table != null)
-            {
-                h ^= table.hashCode();
-            }
-
-            if (column != null)
-            {
-                h ^= column.hashCode();
-            }
+            h ^= column.getSqlExpression().hashCode();
 
             for (int i = 0; i < this.clauses.size(); i++)
             {
@@ -3440,13 +4116,10 @@ public class Criteria implements Seriali
         {
             if (c != null)
             {
-                if (c.getTable() != null)
-                {
-                    s.add(c.getTable());
-                }
+                s.add(c.getColumn().getTableName());
                 for (int i = 0; i < c.getClauses().size(); i++)
                 {
-                    addCriterionTable((Criterion) (c.getClauses().get(i)), s);
+                    addCriterionTable((c.getClauses().get(i)), s);
                 }
             }
         }
@@ -3462,7 +4135,7 @@ public class Criteria implements Seriali
             Criterion[] crita = new Criterion[crits.size()];
             for (int i = 0; i < crits.size(); i++)
             {
-                crita[i] = (Criterion) crits.get(i);
+                crita[i] = crits.get(i);
             }
 
             return crita;
@@ -3498,30 +4171,38 @@ public class Criteria implements Seriali
         /** Version id for serializing. */
         private static final long serialVersionUID = 1L;
 
-        /** the left column of the join condition */
-        private String leftColumn = null;
+        /** the left column of the join condition, not null. */
+        private Column leftColumn = null;
 
-        /** the right column of the join condition */
-        private String rightColumn = null;
+        /** the right column of the join condition, not null. */
+        private Column rightColumn = null;
 
-        /** the type of the join (LEFT JOIN, ...), or null */
+        /** the type of the join (LEFT JOIN, ...), or null. */
         private SqlEnum joinType = null;
 
         /**
          * Constructor
          * @param leftColumn the left column of the join condition;
-         *        might contain an alias name
+         *        might contain an alias name, not null.
          * @param rightColumn the right column of the join condition
-         *        might contain an alias name
+         *        might contain an alias name, not null.
          * @param joinType the type of the join. Valid join types are
          *        null (adding the join condition to the where clause),
          *        SqlEnum.LEFT_JOIN, SqlEnum.RIGHT_JOIN, and SqlEnum.INNER_JOIN
          */
         public Join(
-                final String leftColumn,
-                final String rightColumn,
+                final Column leftColumn,
+                final Column rightColumn,
                 final SqlEnum joinType)
         {
+            if (leftColumn == null)
+            {
+                throw new NullPointerException("leftColumn is null");
+            }
+            if (rightColumn == null)
+            {
+                throw new NullPointerException("rightColumn is null");
+            }
             this.leftColumn = leftColumn;
             this.rightColumn = rightColumn;
             this.joinType = joinType;
@@ -3539,7 +4220,7 @@ public class Criteria implements Seriali
         /**
          * @return the left column of the join condition

[... 65 lines stripped ...]


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