You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by "Henning P. Schmiedehausen" <ma...@hometree.net> on 2001/05/11 12:58:20 UTC

[PATCH] adding AS columns to a Peer

Hi,

this is a report from earlier this week. It adds a method to put "AS" 
columns into a Peer selection without resorting to putting the SQL
fragement into an addSelectColumn call.

This is against the 2001/05/10 turbine.

	Regards
		Henning

diff -urb jakarta-turbine-20010510.orig/src/java/org/apache/turbine/om/peer/BasePeer.java jakarta-turbine-20010510/src/java/org/apache/turbine/om/peer/BasePeer.java
--- jakarta-turbine-20010510.orig/src/java/org/apache/turbine/om/peer/BasePeer.java	Thu May 10 19:00:17 2001
+++ jakarta-turbine-20010510/src/java/org/apache/turbine/om/peer/BasePeer.java	Fri May 11 12:42:24 2001
@@ -75,6 +75,7 @@
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 import org.apache.turbine.TurbineConstants;
@@ -883,6 +884,7 @@
         StringStackBuffer orderBy = criteria.getOrderByColumns();
         boolean ignoreCase = criteria.isIgnoreCase();
         StringStackBuffer select = criteria.getSelectColumns();
+        Hashtable aliases = criteria.getAsColumns();
         StringStackBuffer modifiers = criteria.getSelectModifiers();
 
         for (int i=0; i<modifiers.size(); i++)
@@ -921,6 +923,13 @@
             }
         }
 
+	Iterator it = aliases.keySet().iterator();
+	while(it.hasNext())
+	{
+	  String key = (String)it.next();
+	  selectClause.add((String)aliases.get(key) + " AS " + key);
+	}
+
         Enumeration e = criteria.keys();
         while (e.hasMoreElements())
         {
@@ -1961,6 +1970,7 @@
         StringStackBuffer orderBy = criteria.getOrderByColumns();
         boolean ignoreCase = criteria.isIgnoreCase();
         StringStackBuffer select = criteria.getSelectColumns();
+        Hashtable aliases = criteria.getAsColumns();
         StringStackBuffer modifiers = criteria.getSelectModifiers();
 
         for (int i=0; i<modifiers.size(); i++)
@@ -2005,6 +2015,13 @@
         }
 
         
+	Iterator it = aliases.keySet().iterator();
+	while(it.hasNext())
+	{
+	  String key = (String)it.next();
+	  selectClause.add((String)aliases.get(key) + " AS " + key);
+	}
+
         Enumeration e = criteria.keys();
         while (e.hasMoreElements())
         {
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

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


Re: [PATCH] adding AS columns to a Peer

Posted by "Henning P. Schmiedehausen" <ma...@hometree.net>.
Jon Stevens <jo...@latchkey.com> writes:

What the... emacs got me again. Duh! My original patch was without
tabs. Sorry about this. New patches for both of my last mails
attached.

	Regards
		Henning

>on 5/11/01 3:58 AM, "Henning P. Schmiedehausen" <ma...@hometree.net>
>wrote:

>> +    Iterator it = aliases.keySet().iterator();
>> +    while(it.hasNext())
>> +    {
>> +      String key = (String)it.next();
>> +      selectClause.add((String)aliases.get(key) + " AS " + key);
>> +    }
>> +

>Henning,

>No tabs please. :-)

diff -urb jakarta-turbine.orig/src/java/org/apache/turbine/util/db/Criteria.java jakarta-turbine/src/java/org/apache/turbine/util/db/Criteria.java
--- jakarta-turbine.orig/src/java/org/apache/turbine/util/db/Criteria.java	Thu May 10 19:00:30 2001
+++ jakarta-turbine/src/java/org/apache/turbine/util/db/Criteria.java	Fri May 11 22:18:50 2001
@@ -93,6 +93,7 @@
  * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
  * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
  * @author <a href="mailto:eric@dobbse.net">Eric Dobbs</a>
+ * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  * @version $Id: Criteria.java,v 1.30 2001/05/06 17:06:41 jvanzyl Exp $
  */
 public class Criteria extends Hashtable
@@ -189,6 +190,7 @@
     private StringStackBuffer selectModifiers = new StringStackBuffer();
     private StringStackBuffer selectColumns = new StringStackBuffer();
     private StringStackBuffer orderByColumns = new StringStackBuffer();
+    private Hashtable asColumns = new Hashtable(8);
     private ArrayList joinL = null;
     private ArrayList joinR = null;
 
@@ -416,13 +418,6 @@
         return new Criterion(table,column,value,comparison);
     }
 
-    public Criteria add(Criterion c)
-    {
-        String key = new StringBuffer(c.getTable().length() + c.getColumn().length() + 1).append(c.getTable()).append('.').append(c.getColumn()).toString();
-        super.put(key, c);
-        return this;
-    }
-
     /**
      * Method to return a String table name.
      *
@@ -898,779 +893,2296 @@
     }
 
 
-    /**
-     * This method is a slightly faster alternative to using the
-     * method put().  It also allows code that looks like this:
-     *
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add ( &quot;name&quot;,
-     *                                      &quot;value&quot; );
-     * </code>
+    /* *
+     * Convenience method to add a Key to Criteria.
      *
-     * @param key A String.
-     * @param value An Object.
-     * @return A Criteria.
-     */
+     * @param key A String value to use as key.
+     * @param value A Key.
+     * @return A modified Criteria object.
+     * /
     public Criteria add ( String key,
-                          Object value )
+                          Key value )
     {
-        add(key, value, EQUAL);
+        add( key, value.getInternalObject() );
         return this;
     }
+    */
 
     /**
-     * This method is a slightly faster alternative to using the
-     * method put().  It also allows code that looks like this:
+     * This is the way that you should add a join of two tables.  For
+     * example:
      *
      * <p>
-     * <code>
-     * Criteria crit = new Criteria().add ( &quot;name&quot;,
-     *                                      &quot;value&quot; );
-     * </code>
+     * AND PROJECT.PROJECT_ID=FOO.PROJECT_ID
+     * <p>
      *
-     * @param key A String.
-     * @param value An Object.
-     * @param comparison A String.
-     * @return A Criteria.
+     * 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 add ( String key,
-                          Object value,
-                          String comparison )
+    public Criteria addJoin( String left,
+                             String right)
+    {
+        if ( joinL == null ) 
     {
-        super.put( key, new Criterion(key, value, comparison) );
+            joinL = new ArrayList(3);
+            joinR = new ArrayList(3);
+        }
+        joinL.add(left);
+        joinR.add(right);
+
         return this;
     }
 
     /**
-     * This method is a slightly faster alternative to using the
-     * method put().  It also allows code that looks like this:
-     *
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add ( &quot;name&quot;,
-     *                                      &quot;value&quot; );
-     * </code>
-     *
-     * @param table String name of table.
-     * @param column String name of column.
-     * @param value An Object.
-     * @return A Criteria.
+     * get one side of the set of possible joins.  This method is meant to
+     * be called by BasePeer.
      */
-    public Criteria add ( String table,
-                          String column,
-                          Object value )
+    public List getJoinL()
     {
-        add(table, column, value, EQUAL);
-        return this;
+        return joinL;
+    }
+    /**
+     * get one side of the set of possible joins.  This method is meant to
+     * be called by BasePeer.
+     */
+    public List getJoinR()
+    {
+        return joinR;
     }
 
     /**
-     * This method is a slightly faster alternative to using the
-     * method put().  It also allows code that looks like this:
-     *
-     * <p>
-     * <code>
-     * Criteria crit = new Criteria().add ( &quot;name&quot;,
-     *                                      &quot;value&quot; );
-     * </code>
-     *
-     * @param table String name of table.
-     * @param column String name of column.
-     * @param value An Object.
-     * @param comparison A String.
-     * @return A Criteria.
+     * Adds "ALL " to the SQL statement.
      */
-    public Criteria add ( String table,
-                          String column,
-                          Object value,
-                          String comparison )
+    public void setAll()
     {
-        super.put(
-            new StringBuffer(table.length() + column.length() + 1)
-            .append(table).append('.').append(column).toString(),
-            new Criterion(table, column, value, comparison) );
-        return this;
+        selectModifiers.add(ALL);
     }
 
     /**
-     * Convenience method to add a boolean to Criteria.
-     *
-     * @param key A String value to use as key.
-     * @param value A Boolean.
-     * @return A modified Criteria object.
+     * Adds "DISTINCT " to the SQL statement.
      */
-    public Criteria add ( String key,
-                          boolean value )
+    public void setDistinct()
     {
-        add( key, new Boolean(value) );
-        return this;
+        selectModifiers.add(DISTINCT);
     }
+
     /**
-     * Convenience method to add a boolean to Criteria.
+     * Sets ignore case.
      *
-     * @param key A String value to use as key.
-     * @param value A Boolean.
-     * @param comparison A String.
+     * @param b True if case should be ignored.
      * @return A modified Criteria object.
      */
-    public Criteria add ( String key,
-                          boolean value,
-                          String comparison )
+    public Criteria setIgnoreCase(boolean b)
     {
-        add( key, new Boolean(value), comparison );
+        ignoreCase = b;
         return this;
     }
 
     /**
-     * Convenience method to add an int to Criteria.
+     * Is ignore case on or off?
      *
-     * @param key A String value to use as key.
-     * @param value An int.
-     * @return A modified Criteria object.
+     * @return True if case is ignored.
      */
-    public Criteria add ( String key,
-                          int value )
+    public boolean isIgnoreCase()
     {
-        add( key, new Integer(value) );
-        return this;
+        return ignoreCase;
     }
 
     /**
-     * Convenience method to add an int to Criteria.
+     * Set single record?
      *
-     * @param key A String value to use as key.
-     * @param value An int.
-     * @param comparison A String.
+     * @param b True if a single record should be returned.
      * @return A modified Criteria object.
      */
-    public Criteria add ( String key,
-                          int value,
-                          String comparison )
+    public Criteria setSingleRecord(boolean b)
     {
-        add( key, new Integer(value), comparison );
+        singleRecord = b;
         return this;
     }
 
-    /*
-     * Convenience method to add a long to Criteria.
+    /**
+     * Is single record?
      *
-     * @param key A String value to use as key.
-     * @param value A long.
-     * @return A modified Criteria object.
+     * @return True if a single record is being returned.
      */
-    public Criteria add(String key,
-                        long value)
+    public boolean isSingleRecord()
     {
-        add(key, new Long(value));
-        return this;
+        return singleRecord;
     }
 
-    /*
-     * Convenience method to add a long to Criteria
+    /**
+     * Set cascade.
      *
-     * @param key A String value to use as key.
-     * @param value A long.
-     * @param comparison A String.
+     * @param b True if cascade is set.
      * @return A modified Criteria object.
      */
-    public Criteria add(String key,
-                        long value,
-                        String comparison)
+    public Criteria setCascade(boolean b)
     {
-        add(key, new Long(value), comparison);
+        cascade = b;
         return this;
     }
 
-    /*
-     * Convenience method to add a float to Criteria.
+    /**
+     * Is cascade set?
      *
-     * @param key A String value to use as key.
-     * @param value A float.
-     * @return A modified Criteria object.
+     * @return True if cascade is set.
      */
-    public Criteria add(String key,
-                        float value)
+    public boolean isCascade()
     {
-        add(key, new Float(value));
-        return this;
+        return cascade;
     }
 
-    /*
-     * Convenience method to add a float to Criteria
+    /**
+     * Set limit.
      *
-     * @param key A String value to use as key.
-     * @param value A float.
-     * @param comparison A String.
+     * @param limit An int with the value for limit.
      * @return A modified Criteria object.
      */
-    public Criteria add(String key,
-                        float value,
-                        String comparison)
+    public Criteria setLimit(int limit)
     {
-        add(key, new Float(value), comparison);
+        this.limit = limit;
         return this;
     }
 
-    /*
-     * Convenience method to add a double to Criteria.
+    /**
+     * Get limit.
      *
-     * @param key A String value to use as key.
-     * @param value A double.
-     * @return A modified Criteria object.
+     * @return An int with the value for limit.
      */
-    public Criteria add(String key,
-                        double value)
+    public int getLimit()
     {
-        add(key, new Double(value));
-        return this;
+        return limit;
     }
 
-    /*
-     * Convenience method to add a double to Criteria
+    /**
+     * Set offset.
      *
-     * @param key A String value to use as key.
-     * @param value A double.
-     * @param comparison A String.
+     * @param offset An int with the value for offset.
      * @return A modified Criteria object.
      */
-    public Criteria add(String key,
-                        double value,
-                        String comparison)
+    public Criteria setOffset(int offset)
     {
-        add(key, new Double(value), comparison);
+        this.offset = offset;
         return this;
     }
 
     /**
-     * This method lets you put a Date object into the criteria object
-     * by specifying the year, month, and date.
+     * Get offset.
      *
-     * @param key A String value to use as key.
-     * @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.
+     * @return An int with the value for offset.
      */
-    public Criteria addTime( String key,
-                             int year,
-                             int month,
-                             int date )
+    public int getOffset()
     {
-        add( key, new GregorianCalendar(year, month, date) );
-        return this;
+        return offset;
     }
 
     /**
-     * This method lets you put a Date object into the criteria object
-     * by specifying the year, month, and date.
+     * Add select column.
      *
-     * @param key A String value to use as key.
-     * @param year An int with the year.
-     * @param month An int with the month.
-     * @param date An int with the date.
-     * @param comparison A String.
+     * @param name A String with the name of the select column.
      * @return A modified Criteria object.
      */
-    public Criteria addTime( String key,
-                             int year,
-                             int month,
-                             int date,
-                             String comparison)
+    public Criteria addSelectColumn( String name )
     {
-        add( key, new GregorianCalendar(year, month, date), comparison );
+        selectColumns.add( name );
         return this;
     }
 
-    /* *
-     * Convenience method to add a Key to Criteria.
+    /**
+     * Get select columns.
      *
-     * @param key A String value to use as key.
-     * @param value A Key.
-     * @return A modified Criteria object.
-     * /
-    public Criteria add ( String key,
-                          Key value )
+     * @return A StringStackBuffer with the name of the select
+     * columns.
+     */
+    public StringStackBuffer getSelectColumns()
     {
-        add( key, value.getInternalObject() );
-        return this;
+        return selectColumns;
     }
-    */
 
     /**
-     * This is the way that you should add a join of two tables.  For
-     * example:
-     *
-     * <p>
-     * AND PROJECT.PROJECT_ID=FOO.PROJECT_ID
+   * Add an AS clause to the select columns. Usage:
      * <p>
+   * <code>
      *
-     * left = PROJECT.PROJECT_ID
-     * right = FOO.PROJECT_ID
+   * Criteria myCrit = new Criteria();
+   * myCrit.addAsColumn("alias", "ALIAS("+MyPeer.ID+")");
+   *
+   * </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.
      *
-     * @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)
-    {
-        if ( joinL == null ) 
-        {
-            joinL = new ArrayList(3);
-            joinR = new ArrayList(3);
-        }
-        joinL.add(left);
-        joinR.add(right);
 
+  public Criteria addAsColumn(String name, 
+                              String clause)
+  {
+    asColumns.put(name, clause);
         return this;
     }
 
     /**
-     * get one side of the set of possible joins.  This method is meant to
-     * be called by BasePeer.
+   * Get the column aliases.
+   *
+   * @return A Hashtable which map the column alias names
+   * to the alias clauses.
      */
-    public List getJoinL()
+
+  public Hashtable getAsColumns()
     {
-        return joinL;
+    return asColumns;
     }
+
     /**
-     * get one side of the set of possible joins.  This method is meant to
-     * be called by BasePeer.
+     * Get select modifiers.
+     *
+     * @return A StringStackBuffer with the select modifiers.
      */
-    public List getJoinR()
+    public StringStackBuffer getSelectModifiers()
     {
-        return joinR;
+        return selectModifiers;
     }
 
     /**
-     * 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.
-     *
-     * @param key A String value to use as key.
-     * @param values An Object[] with the allowed values.
-     * @return A modified Criteria object.
+     * @deprecated Use addAscendingOrderByColumn() instead.
      */
-    public Criteria addIn(String key,
-                          Object[] values)
+    public Criteria addOrderByColumn( String name )
     {
-        add(key, (Object)values, Criteria.IN);
+        orderByColumns.add( name );
         return this;
     }
 
     /**
-     * Adds an 'IN' clause with the criteria supplied as an int array.
-     * For example:
-     *
-     * <p>
-     * FOO.ID IN ('2', '3', '7')
-     * <p>
-     *
-     * where 'values' contains those three integers.
+     * Add order by column name, explicitly specifying ascending.
      *
-     * @param key A String value to use as key.
-     * @param values An int[] with the allowed values.
+     * @param name The name of the column to order by.
      * @return A modified Criteria object.
      */
-    public Criteria addIn(String key,
-                          int[] values)
+    public Criteria addAscendingOrderByColumn( String name )
     {
-        add(key, (Object)values, Criteria.IN);
+        orderByColumns.add( name + " " + ASC );
         return this;
     }
 
     /**
-     * Adds an 'IN' clause with the criteria supplied as a Vector.
-     * 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.
+     * Add order by column name, explicitly specifying descending.
      *
-     * @param key A String value to use as key.
-     * @param values A Vector with the allowed values.
+     * @param name The name of the column to order by.
      * @return A modified Criteria object.
      */
-    public Criteria addIn(String key,
-                          Vector values)
+    public Criteria addDescendingOrderByColumn( String name )
     {
-        add(key, (Object)values, Criteria.IN);
+        orderByColumns.add( name + " " + DESC );
         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.
+     * Get order by columns.
      *
-     * @param key A String value to use as key.
-     * @param values An Object[] with the disallowed values.
-     * @return A modified Criteria object.
+     * @return A StringStackBuffer with the name of the order columns.
      */
-    public Criteria addNotIn(String key,
-                             Object[] values)
+    public StringStackBuffer getOrderByColumns()
     {
-        add(key, (Object)values, Criteria.NOT_IN);
-        return this;
+        return orderByColumns;
     }
 
     /**
-     * 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.
+     * Remove an object from the criteria.
      *
-     * @param key A String value to use as key.
-     * @param values An int[] with the disallowed values.
-     * @return A modified Criteria object.
+     * @param key A String with the key to be removed.
+     * @return The removed object.
      */
-    public Criteria addNotIn(String key,
-                             int[] values)
+    public Object remove(String key)
     {
-        add(key, (Object)values, Criteria.NOT_IN);
-        return this;
+        Object foo = super.remove(key);
+        if (foo instanceof Criterion)
+            return ((Criterion)foo).getValue();
+        return foo;
     }
 
     /**
-     * Adds a 'NOT IN' clause with the criteria supplied as a Vector.
-     * 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.
+     * Build a string representation of the Criteria.
      *
-     * @param key A String value to use as key.
-     * @param values A Vector with the disallowed values.
-     * @return A modified Criteria object.
+     * @return A String with the representation of the Criteria.
      */
-    public Criteria addNotIn(String key,
-                             Vector values)
+    public String toString()
     {
-        add(key, (Object)values, Criteria.NOT_IN);
-        return this;
+        StringBuffer sb = new StringBuffer("Criteria:: ");
+        Enumeration e = keys();
+        while (e.hasMoreElements())
+        {
+            String key = (String)e.nextElement();
+            sb.append(key).append("<=>")
+                .append(super.get(key).toString()).append(":  ");
     }
 
-    /**
-     * Adds "ALL " to the SQL statement.
-     */
-    public void setAll()
+        try
     {
-        selectModifiers.add(ALL);
+            sb.append("\nCurrent Query SQL (may not be complete or applicable): ")
+              .append(BasePeer.createQueryString(this));
     }
+        catch (Exception exc) {}
 
-    /**
-     * Adds "DISTINCT " to the SQL statement.
-     */
-    public void setDistinct()
-    {
-        selectModifiers.add(DISTINCT);
+        return sb.toString();
     }
 
+
     /**
-     * Sets ignore case.
-     *
-     * @param b True if case should be ignored.
-     * @return A modified Criteria object.
+     * This method checks another Criteria to see if they contain
+     * the same attributes and hashtable entries.
      */
-    public Criteria setIgnoreCase(boolean b)
+    public boolean equals(Object crit)
     {
-        ignoreCase = b;
-        return this;
+        boolean isEquiv = false;
+        if ( crit == null || !(crit instanceof Criteria) ) 
+        {
+            isEquiv = false;   
     }
 
-    /**
-     * Is ignore case on or off?
-     *
-     * @return True if case is ignored.
-     */
-    public boolean isIgnoreCase()
+        else if ( this == crit ) 
     {
-        return ignoreCase;
+            isEquiv = true;
     }
 
-    /**
-     * Set single record?
-     *
-     * @param b True if a single record should be returned.
-     * @return A modified Criteria object.
-     */
-    public Criteria setSingleRecord(boolean b)
+        else if ( this.size() == ((Criteria)crit).size() )
     {
-        singleRecord = b;
-        return this;
+            Criteria criteria = (Criteria)crit;
+            if ( this.offset == criteria.getOffset() 
+                 && this.limit == criteria.getLimit()
+                 && ignoreCase == criteria.isIgnoreCase()
+                 && singleRecord == criteria.isSingleRecord()
+                 && cascade == criteria.isCascade()
+                 && dbName.equals(criteria.getDbName())
+                 && selectModifiers.equals(criteria.getSelectModifiers())
+                 && selectColumns.equals(criteria.getSelectColumns())
+                 && orderByColumns.equals(criteria.getOrderByColumns())
+                 && asColumns.equals(criteria.getAsColumns())
+               ) 
+            {
+                isEquiv = true;
+                for (Enumeration e=criteria.keys(); e.hasMoreElements(); )
+                {
+                    String key = (String)e.nextElement();
+                    if ( this.containsKey(key) )
+                    {
+                        Criterion a = this.getCriterion(key);
+                        Criterion b = criteria.getCriterion(key);
+                        if ( !a.equals(b) ) 
+                        {
+                            isEquiv = false;
+                            break;
+                        }                        
+                    }
+                    else
+                    {
+                        isEquiv = false;
+                        break;
+                    }
+                }
+            }
     }
 
-    /**
-     * Is single record?
+        return isEquiv;
+    }
+
+    /*
+     *------------------------------------------------------------------------
      *
-     * @return True if a single record is being returned.
+     * Start of the "add" methods
+     *
+     *------------------------------------------------------------------------
      */
-    public boolean isSingleRecord()
-    {
-        return singleRecord;
-    }
+    
 
     /**
-     * Set cascade.
+     * This method adds a prepared Criterion object to the Criteria.  
+     * You can get a new, empty Criterion object with the
+     * getNewCriterion() method. If a criterion for the requested column 
+     * already exists, it is replaced. This is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria();
+     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5), Criteria.LESS_THAN);
+     * crit.add(c);
+     * </code>
+     *
+     * @param c A Criterion object
      *
-     * @param b True if cascade is set.
      * @return A modified Criteria object.
      */
-    public Criteria setCascade(boolean b)
+  
+    public Criteria add( Criterion c)
     {
-        cascade = b;
+        StringBuffer sb = new StringBuffer(c.getTable().length() + c.getColumn().length() + 1);
+        sb.append(c.getTable());
+        sb.append('.');
+        sb.append(c.getColumn());
+        super.put(sb.toString(), c);
         return this;
     }
 
     /**
-     * Is cascade set?
+     * 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:
      *
-     * @return True if cascade is set.
+     * <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 boolean isCascade()
+    
+    public Criteria add( String column,
+                         Object value )
     {
-        return cascade;
+        add(column, value, EQUAL);
+        return this;
     }
 
     /**
-     * Set limit.
+     * 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; 
+     *                                      &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 add(table, column, value) method.
+     *
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison A String.
      *
-     * @param limit An int with the value for limit.
      * @return A modified Criteria object.
      */
-    public Criteria setLimit(int limit)
+    
+    public Criteria add( String column,
+                         Object value,
+                         String comparison )
     {
-        this.limit = limit;
+        super.put( column, new Criterion(column, value, comparison) );
         return this;
     }
 
     /**
-     * Get limit.
+     * 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 follows:
      *
-     * @return An int with the value for limit.
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().add(&quot;table&quot;,
+     *                                      &quot;column&quot;,
+     *                                      &quot;value&quot; );
+     * </code>
+     *
+     * An EQUAL comparison is used for column and value.
+     *
+     * @param table Name of the table which contains the column
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
      */
-    public int getLimit()
+    
+    public Criteria add( String table,
+                         String column,
+                         Object value )
     {
-        return limit;
+        add(table, column, value, EQUAL);
+        return this;
     }
 
     /**
-     * Set offset.
+     * 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 follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().add(&quot;table&quot;,
+     *                                      &quot;column&quot;,
+     *                                      &quot;value&quot;,
+     *                                      &quot;Criterion.GREATER_THAN&quot;);
+     * </code>
+     *
+     * Any comparison can be used.
+     *
+     * @param table Name of table which contains the column
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison String describing how to compare the column with the value
      *
-     * @param offset An int with the value for offset.
      * @return A modified Criteria object.
      */
-    public Criteria setOffset(int offset)
+    
+    public Criteria add( String table,
+                         String column,
+                         Object value,
+                         String comparison )
     {
-        this.offset = offset;
+        StringBuffer sb = new StringBuffer(table.length()+column.length()+1);
+        sb.append(table);
+        sb.append('.');
+        sb.append(column);
+        super.put(sb.toString(),new Criterion(table, column, value, comparison));
         return this;
     }
 
     /**
-     * Get offset.
+     * Convenience method to add a boolean to Criteria. 
+     * Equal to
      *
-     * @return An int with the value for offset.
+     * <p>
+     * <code>
+     * add(column, new Boolean(value), EQUAL);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A Boolean.
+     *
+     * @return A modified Criteria object.
      */
-    public int getOffset()
+    
+    public Criteria add( String column,
+                         boolean value )
     {
-        return offset;
+        add(column, new Boolean(value) );
+        return this;
     }
 
     /**
-     * Add select column.
+     * Convenience method to add a boolean to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * add(column, new Boolean(value), comparison);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A Boolean.
+     * @param comparison String describing how to compare the column with the value
      *
-     * @param name A String with the name of the select column.
      * @return A modified Criteria object.
      */
-    public Criteria addSelectColumn( String name )
+
+    public Criteria add( String column,
+                         boolean value,
+                         String comparison )
     {
-        selectColumns.add( name );
+        add(column, new Boolean(value), comparison );
         return this;
     }
 
     /**
-     * Get select columns.
+     * Convenience method to add an int to Criteria.
+     * Equal to
      *
-     * @return A StringStackBuffer with the name of the select
-     * columns.
+     * <p>
+     * <code>
+     * add(column, new Integer(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value An int.
+     *
+     * @return A modified Criteria object.
      */
-    public StringStackBuffer getSelectColumns()
+
+    public Criteria add( String column,
+                         int value )
     {
-        return selectColumns;
+        add(column, new Integer(value) );
+        return this;
     }
 
     /**
-     * Get select modifiers.
+     * Convenience method to add an int to Criteria.
+     * Equal to
      *
-     * @return A StringStackBuffer with the select modifiers.
+     * <p>
+     * <code>
+     * add(column, new Integer(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value An int.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
      */
-    public StringStackBuffer getSelectModifiers()
+
+    public Criteria add( String column,
+                         int value,
+                         String comparison )
     {
-        return selectModifiers;
+        add(column, new Integer(value), comparison );
+        return this;
     }
 
     /**
-     * @deprecated Use addAscendingOrderByColumn() instead.
+     * Convenience method to add a long to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * add(column, new Long(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A long.
+     *
+     * @return A modified Criteria object.
      */
-    public Criteria addOrderByColumn( String name )
+
+    public Criteria add( String column,
+                         long value)
     {
-        orderByColumns.add( name );
+        add(column, new Long(value));
         return this;
     }
 
     /**
-     * Add order by column name, explicitly specifying ascending.
+     * Convenience method to add a long to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * add(column, new Long(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A long.
+     * @param comparison String describing how to compare the column with the value
      *
-     * @param name The name of the column to order by.
      * @return A modified Criteria object.
      */
-    public Criteria addAscendingOrderByColumn( String name )
+
+    public Criteria add( String column,
+                         long value,
+                         String comparison)
     {
-        orderByColumns.add( name + " " + ASC );
+        add(column, new Long(value), comparison);
         return this;
     }
 
     /**
-     * Add order by column name, explicitly specifying descending.
+     * Convenience method to add a float to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * add(column, new Float(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A float.
      *
-     * @param name The name of the column to order by.
      * @return A modified Criteria object.
      */
-    public Criteria addDescendingOrderByColumn( String name )
+
+    public Criteria add( String column,
+                         float value)
     {
-        orderByColumns.add( name + " " + DESC );
+        add(column, new Float(value));
         return this;
     }
 
     /**
-     * Get order by columns.
+     * Convenience method to add a float to Criteria
+     * Equal to
      *
-     * @return A StringStackBuffer with the name of the order columns.
+     * <p>
+     * <code>
+     * add(column, new Float(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A float.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
      */
-    public StringStackBuffer getOrderByColumns()
+
+    public Criteria add( String column,
+                         float value,
+                         String comparison)
     {
-        return orderByColumns;
+        add(column, new Float(value), comparison);
+        return this;
     }
 
     /**
-     * Remove an object from the criteria.
+     * Convenience method to add a double to Criteria.
+     * Equal to
      *
-     * @param key A String with the key to be removed.
-     * @return The removed object.
+     * <p>
+     * <code>
+     * add(column, new Double(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A double.
+     *
+     * @return A modified Criteria object.
      */
-    public Object remove(String key)
+
+    public Criteria add( String column,
+                         double value)
     {
-        Object foo = super.remove(key);
-        if (foo instanceof Criterion)
-            return ((Criterion)foo).getValue();
-        return foo;
+        add(column, new Double(value));
+        return this;
     }
 
     /**
-     * Build a string representation of the Criteria.
+     * Convenience method to add a double to Criteria
+     * Equal to
      *
-     * @return A String with the representation of the Criteria.
+     * <p>
+     * <code>
+     * add(column, new Double(value), comparison);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A double.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
      */
-    public String toString()
-    {
-        StringBuffer sb = new StringBuffer("Criteria:: ");
-        Enumeration e = keys();
-        while (e.hasMoreElements())
-        {
-            String key = (String)e.nextElement();
-            sb.append(key).append("<=>")
-                .append(super.get(key).toString()).append(":  ");
-        }
 
-        try
+    public Criteria add( String column,
+                         double value,
+                         String comparison)
         {
-            sb.append("\nCurrent Query SQL (may not be complete or applicable): ")
-              .append(BasePeer.createQueryString(this));
-        }
-        catch (Exception exc) {}
-
-        return sb.toString();
+        add(column, new Double(value), comparison);
+        return this;
     }
 
-
     /**
-     * This method checks another Criteria to see if they contain
-     * the same attributes and hashtable entries.
+     * @deprecated These routines were wrongly named and are misleading. Use addDate() instead.
      */
-    public boolean equals(Object crit)
-    {
-        boolean isEquiv = false;
-        if ( crit == null || !(crit instanceof Criteria) ) 
-        {
-            isEquiv = false;   
-        }
 
-        else if ( this == crit ) 
+    public Criteria addTime( String column,
+                             int year,
+                             int month,
+                             int date )
         {
-            isEquiv = true;
+        add(column, new GregorianCalendar(year, month, date) );
+        return this;
         }
         
-        else if ( this.size() == ((Criteria)crit).size() )
+    /**
+     * @deprecated These routines were wrongly named and are misleading. Use addDate() instead.
+     */
+
+    public Criteria addTime( String column,
+                             int year,
+                             int month,
+                             int date,
+                             String comparison)
+    {
+        add(column, new GregorianCalendar(year, month, date), 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.
+     * @param date An int with the date.
+     * @return A modified Criteria object.
+     */
+
+    public Criteria addDate( String column,
+                             int year,
+                             int month,
+                             int date )
+    {
+        add(column, new GregorianCalendar(year, month, date) );
+        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.
+     * @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( String column,
+                             int year,
+                             int month,
+                             int date,
+                             String comparison)
+    {
+        add(column, new GregorianCalendar(year, month, date), comparison );
+        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
+     * 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(String column,
+                          Object[] values)
+    {
+        add(column, (Object)values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as an int array.
+     * For example:
+     *
+     * <p>
+     * FOO.ID IN ('2', '3', '7')
+     * <p>
+     *
+     * where 'values' contains those three integers.
+     *
+     * If a criterion for the requested column already exists, it is
+     * replaced. 
+     *
+     * @param column The column to run the comparison on
+     * @param values An int[] with the allowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria addIn(String column,
+                          int[] values)
+    {
+        add(column, (Object)values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a Vector.
+     * 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 A Vector with the allowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria addIn(String column,
+                          Vector values)
+    {
+        add(column, (Object)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(String column,
+                             Object[] values)
+    {
+        add(column, (Object)values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /**
+     * 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
+     * replaced. 
+     *
+     * @param column The column to run the comparison on
+     * @param values An int[] with the disallowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria addNotIn(String column,
+                             int[] values)
+    {
+        add(column, (Object)values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as a Vector.
+     * 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 A Vector with the disallowed values.
+     * @return A modified Criteria object.
+     */
+
+    public Criteria addNotIn(String column,
+                             Vector values)
+    {
+        add(column, (Object)values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /*
+     *------------------------------------------------------------------------
+     *
+     * Start of the "and" methods
+     *
+     *------------------------------------------------------------------------
+     */
+    
+    /**
+     * This method adds a prepared Criterion object to the Criteria.  
+     * You can get a new, empty Criterion object with the
+     * getNewCriterion() method. If a criterion for the requested column 
+     * already exists, it is "AND"ed to the existing criterion. 
+     * This is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria();
+     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5), Criteria.LESS_THAN);
+     * crit.and(c);
+     * </code>
+     *
+     * @param c A Criterion object
+     *
+     * @return A modified Criteria object.
+     */
+  
+    public Criteria and( Criterion c)
+    {
+        Criterion oc = getCriterion(c.getTable()+"."+c.getColumn());
+    
+        if(oc == null)
+            add(c);
+        else
+            oc.and(c);
+
+        return this;
+    }    
+  
+    /**
+     * This method adds a new criterion to the list of criterias. If a 
+     * criterion for the requested column already exists, it is
+     * "AND"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 )
+    {
+        and(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
+     * "AND"ed to the existing criterion. If is used as follow:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().and(&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 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,
+                         String comparison )
+    {
+        Criterion oc = getCriterion(column);
+        Criterion nc = new Criterion(column, value, comparison);
+
+        if(oc == null)
+            super.put( column, nc);
+        else
+            oc.and(nc);
+
+        return this;
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias. 
+     * If a criterion for the requested column already exists, it is
+     * "AND"ed to the existing criterion. If is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().and(&quot;table&quot;,
+     *                                      &quot;column&quot;,
+     *                                      &quot;value&quot; );
+     * </code>
+     *
+     * An EQUAL comparison is used for column and value.
+     *
+     * @param table Name of the table which contains the column
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria and( String table,
+                         String column,
+                         Object value )
+    {
+        and(table, 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
+     * "AND"ed to the existing criterion. If is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().and(&quot;table&quot;,
+     *                                      &quot;column&quot;,
+     *                                      &quot;value&quot;,
+     *                                      &quot;Criterion.GREATER_THAN&quot;);
+     * </code>
+     *
+     * Any comparison can be used.
+     *
+     * @param table Name of table which contains the column
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria and( String table,
+                         String column,
+                         Object value,
+                         String comparison )
+    {
+        StringBuffer sb = new StringBuffer(table.length()+column.length()+1);
+        sb.append(table);
+        sb.append('.');
+        sb.append(column);
+
+        Criterion oc = getCriterion(table, column);
+        Criterion nc = new Criterion(table, column, value, comparison);
+
+        if(oc == null)
+            super.put(sb.toString(),nc);
+        else
+            oc.and(nc);
+
+        return this;
+    }
+
+    /**
+     * Convenience method to add a boolean to Criteria. 
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Boolean(value), EQUAL);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A Boolean.
+     *
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria and( String column,
+                         boolean value )
+    {
+        and(column, new Boolean(value) );
+        return this;
+    }
+
+    /**
+     * Convenience method to add a boolean to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Boolean(value), comparison);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A Boolean.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         boolean value,
+                         String comparison )
+    {
+        and(column, new Boolean(value), comparison );
+        return this;
+    }
+
+    /**
+     * Convenience method to add an int to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Integer(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value An int.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         int value )
+    {
+        and(column, new Integer(value) );
+        return this;
+    }
+
+    /**
+     * Convenience method to add an int to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Integer(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value An int.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         int value,
+                         String comparison )
+    {
+        and(column, new Integer(value), comparison );
+        return this;
+    }
+
+    /**
+     * Convenience method to add a long to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Long(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A long.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         long value)
+    {
+        and(column, new Long(value));
+        return this;
+    }
+
+    /**
+     * Convenience method to add a long to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Long(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A long.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         long value,
+                         String comparison)
+    {
+        and(column, new Long(value), comparison);
+        return this;
+    }
+
+    /**
+     * Convenience method to add a float to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Float(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A float.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         float value)
+    {
+        and(column, new Float(value));
+        return this;
+    }
+
+    /**
+     * Convenience method to add a float to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Float(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A float.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         float value,
+                         String comparison)
+    {
+        and(column, new Float(value), comparison);
+        return this;
+    }
+
+    /**
+     * Convenience method to add a double to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Double(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A double.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         double value)
+    {
+        and(column, new Double(value));
+        return this;
+    }
+
+    /**
+     * Convenience method to add a double to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * and(column, new Double(value), comparison);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A double.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria and( String column,
+                         double value,
+                         String comparison)
+    {
+        and(column, new Double(value), 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) );
+        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( String column,
+                             int year,
+                             int month,
+                             int date,
+                             String comparison)
+    {
+        and(column, new GregorianCalendar(year, month, date), comparison );
+        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
+     * "AND"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)
+    {
+        and(column, (Object)values, Criteria.IN);
+        return this;
+    }
+
+    /**
+       * Adds an 'IN' clause with the criteria supplied as an int array.
+       * For example:
+       *
+     * <p>
+     * FOO.ID IN ('2', '3', '7')
+     * <p>
+     *
+     * where 'values' contains those three integers.
+     *
+     * If a criterion for the requested column already exists, it is
+     * "AND"ed to the existing criterion. 
+     *
+     * @param column The column to run the comparison on
+     * @param values An int[] with the allowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria andIn(String column,
+                          int[] values)
+    {
+        and(column, (Object)values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a Vector.
+     * 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
+     * "AND"ed to the existing criterion. 
+     *
+     * @param column The column to run the comparison on
+     * @param values A Vector with the allowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria andIn(String column,
+                          Vector values)
+    {
+        and(column, (Object)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
+     * "AND"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(String column,
+                             Object[] values)
+    {
+        and(column, (Object)values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /**
+     * 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
+     * "AND"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(String column,
+                             int[] values)
+    {
+        and(column, (Object)values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as a Vector.
+     * 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
+     * "AND"ed to the existing criterion. 
+     *
+     * @param column The column to run the comparison on
+     * @param values A Vector with the disallowed values.
+     * @return A modified Criteria object.
+     */
+
+    public Criteria andNotIn(String column,
+                             Vector values)
+    {
+        and(column, (Object)values, Criteria.NOT_IN);
+        return this;
+    }
+
+    /*
+     *------------------------------------------------------------------------
+     *
+     * Start of the "or" methods
+     *
+     *------------------------------------------------------------------------
+     */
+
+    /**
+     * This method adds a prepared Criterion object to the Criteria.  
+     * You can get a new, empty Criterion object with the
+     * getNewCriterion() method. If a criterion for the requested column 
+     * already exists, it is "OR"ed to the existing criterion. 
+     * This is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria();
+     * Criteria.Criterion c = crit.getNewCriterion(BasePeer.ID, new Integer(5), Criteria.LESS_THAN);
+     * crit.or(c);
+     * </code>
+     *
+     * @param c A Criterion object
+     *
+     * @return A modified Criteria object.
+     */
+  
+    public Criteria or( Criterion c)
+    {
+        Criterion oc = getCriterion(c.getTable()+"."+c.getColumn());
+    
+        if(oc == null)
+            add(c);
+        else
+            oc.or(c);
+
+        return this;
+    }    
+  
+    /**
+     * This method adds a new criterion to the list of criterias. If a 
+     * criterion for the requested column already exists, it is
+     * "OR"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);
+        return this;
+    }
+  
+    /**
+     * This method adds a new criterion to the list of criterias. 
+     * If a criterion for the requested column already exists, it is
+     * "OR"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,
+                        String comparison )
+    {
+        Criterion oc = getCriterion(column);
+        Criterion nc = new Criterion(column, value, comparison);
+
+        if(oc == null)
+            super.put( column, nc);
+        else
+            oc.or(nc);
+
+        return this;
+    }
+
+    /**
+     * This method adds a new criterion to the list of criterias. 
+     * If a criterion for the requested column already exists, it is
+     * "OR"ed to the existing criterion. If is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().or(&quot;table&quot;,
+     *                                      &quot;column&quot;,
+     *                                      &quot;value&quot; );
+     * </code>
+     *
+     * An EQUAL comparison is used for column and value.
+     *
+     * @param table Name of the table which contains the column
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria or( String table,
+                        String column,
+                        Object value )
+    {
+        or(table, 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
+     * "OR"ed to the existing criterion. If is used as follows:
+     *
+     * <p>
+     * <code>
+     * Criteria crit = new Criteria().or(&quot;table&quot;,
+     *                                      &quot;column&quot;,
+     *                                      &quot;value&quot;,
+     *                                      &quot;Criterion.GREATER_THAN&quot;);
+     * </code>
+     *
+     * Any comparison can be used.
+     *
+     * @param table Name of table which contains the column
+     * @param column The column to run the comparison on
+     * @param value An Object.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria or( String table,
+                        String column,
+                        Object value,
+                        String comparison )
+    {
+        StringBuffer sb = new StringBuffer(table.length()+column.length()+1);
+        sb.append(table);
+        sb.append('.');
+        sb.append(column);
+
+        Criterion oc = getCriterion(table, column);
+        Criterion nc = new Criterion(table, column, value, comparison);
+        if(oc == null)
+            super.put(sb.toString(), nc);
+        else
+            oc.or(nc);
+
+        return this;
+    }
+
+    /**
+     * Convenience method to add a boolean to Criteria. 
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Boolean(value), EQUAL);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A Boolean.
+     *
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria or( String column,
+                        boolean value )
+    {
+        or(column, new Boolean(value) );
+        return this;
+    }
+
+    /**
+     * Convenience method to add a boolean to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Boolean(value), comparison);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A Boolean.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        boolean value,
+                        String comparison )
+    {
+        or(column, new Boolean(value), comparison );
+        return this;
+    }
+
+    /**
+     * Convenience method to add an int to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Integer(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value An int.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        int value )
+    {
+        or(column, new Integer(value) );
+        return this;
+    }
+
+    /**
+     * Convenience method to add an int to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Integer(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value An int.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        int value,
+                        String comparison )
+    {
+        or(column, new Integer(value), comparison );
+        return this;
+    }
+
+    /**
+     * Convenience method to add a long to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Long(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A long.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        long value)
+    {
+        or(column, new Long(value));
+        return this;
+    }
+
+    /**
+     * Convenience method to add a long to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Long(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A long.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        long value,
+                        String comparison)
         {
-            Criteria criteria = (Criteria)crit;
-            if ( this.offset == criteria.getOffset() 
-                 && this.limit == criteria.getLimit()
-                 && ignoreCase == criteria.isIgnoreCase()
-                 && singleRecord == criteria.isSingleRecord()
-                 && cascade == criteria.isCascade()
-                 && dbName.equals(criteria.getDbName())
-                 && selectModifiers.equals(criteria.getSelectModifiers())
-                 && selectColumns.equals(criteria.getSelectColumns())
-                 && orderByColumns.equals(criteria.getOrderByColumns())
-               ) 
+        or(column, new Long(value), comparison);
+        return this;
+    }
+
+    /**
+     * Convenience method to add a float to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Float(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A float.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        float value)
             {
-                isEquiv = true;
-                for (Enumeration e=criteria.keys(); e.hasMoreElements(); )
+        or(column, new Float(value));
+        return this;
+    }
+
+    /**
+     * Convenience method to add a float to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Float(value), comparison);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A float.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        float value,
+                        String comparison)
                 {
-                    String key = (String)e.nextElement();
-                    if ( this.containsKey(key) )
+        or(column, new Float(value), comparison);
+        return this;
+    }
+
+    /**
+     * Convenience method to add a double to Criteria.
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Double(value), EQUAL);
+     * </code>
+     *
+     *
+     * @param column The column to run the comparison on
+     * @param value A double.
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        double value)
                     {
-                        Criterion a = this.getCriterion(key);
-                        Criterion b = criteria.getCriterion(key);
-                        if ( !a.equals(b) ) 
+        or(column, new Double(value));
+        return this;
+    }
+
+    /**
+     * Convenience method to add a double to Criteria
+     * Equal to
+     *
+     * <p>
+     * <code>
+     * or(column, new Double(value), comparison);
+     * </code>
+     *
+     * @param column The column to run the comparison on
+     * @param value A double.
+     * @param comparison String describing how to compare the column with the value
+     *
+     * @return A modified Criteria object.
+     */
+
+    public Criteria or( String column,
+                        double value,
+                        String comparison)
                         {
-                            isEquiv = false;
-                            break;
+        or(column, new Double(value), comparison);
+        return this;
                         }                        
+
+    /**
+     * 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), 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 )
+    {
+        or(column, new GregorianCalendar(year, month, date) );
+        return this;
                     }
-                    else
+
+    /**
+     * 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,
+                            String comparison)
                     {
-                        isEquiv = false;
-                        break;
+        or(column, new GregorianCalendar(year, month, date), comparison );
+        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
+     * "OR"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)
+    {
+        or(column, (Object)values, Criteria.IN);
+        return this;
+    }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as an int array.
+     * For example:
+     *
+     * <p>
+     * FOO.ID IN ('2', '3', '7')
+     * <p>
+     *
+     * where 'values' contains those three integers.
+     *
+     * If a criterion for the requested column already exists, it is
+     * "OR"ed to the existing criterion. 
+     *
+     * @param column The column to run the comparison on
+     * @param values An int[] with the allowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria orIn(String column,
+                         int[] values)
+    {
+        or(column, (Object)values, Criteria.IN);
+        return this;
                     }
+
+    /**
+     * Adds an 'IN' clause with the criteria supplied as a Vector.
+     * 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
+     * "OR"ed to the existing criterion. 
+     *
+     * @param column The column to run the comparison on
+     * @param values A Vector with the allowed values.
+     * @return A modified Criteria object.
+     */
+    
+    public Criteria orIn(String column,
+                         Vector values)
+    {
+        or(column, (Object)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
+     * "OR"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(String column,
+                            Object[] values)
+    {
+        or(column, (Object)values, Criteria.NOT_IN);
+        return this;
             }
+
+    /**
+     * 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
+     * "OR"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 orNotIn(String column,
+                            int[] values)
+    {
+        or(column, (Object)values, Criteria.NOT_IN);
+        return this;
         }
 
-        return isEquiv;
+    /**
+     * Adds a 'NOT IN' clause with the criteria supplied as a Vector.
+     * 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
+     * "OR"ed to the existing criterion. 
+     *
+     * @param column The column to run the comparison on
+     * @param values A Vector with the disallowed values.
+     * @return A modified Criteria object.
+     */
+
+    public Criteria orNotIn(String column,
+                            Vector values)
+    {
+        or(column, (Object)values, Criteria.NOT_IN);
+        return this;
     }
 
     /**


diff -urb jakarta-turbine.orig/src/java/org/apache/turbine/om/peer/BasePeer.java jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer.java
--- jakarta-turbine.orig/src/java/org/apache/turbine/om/peer/BasePeer.java	Thu May 10 19:00:17 2001
+++ jakarta-turbine/src/java/org/apache/turbine/om/peer/BasePeer.java	Fri May 11 22:19:06 2001
@@ -75,6 +75,7 @@
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 import org.apache.turbine.TurbineConstants;
@@ -883,6 +884,7 @@
         StringStackBuffer orderBy = criteria.getOrderByColumns();
         boolean ignoreCase = criteria.isIgnoreCase();
         StringStackBuffer select = criteria.getSelectColumns();
+        Hashtable aliases = criteria.getAsColumns();
         StringStackBuffer modifiers = criteria.getSelectModifiers();
 
         for (int i=0; i<modifiers.size(); i++)
@@ -921,6 +923,13 @@
             }
         }
 
+        Iterator it = aliases.keySet().iterator();
+        while(it.hasNext())
+        {
+          String key = (String)it.next();
+          selectClause.add((String)aliases.get(key) + " AS " + key);
+        }
+
         Enumeration e = criteria.keys();
         while (e.hasMoreElements())
         {
@@ -1961,6 +1970,7 @@
         StringStackBuffer orderBy = criteria.getOrderByColumns();
         boolean ignoreCase = criteria.isIgnoreCase();
         StringStackBuffer select = criteria.getSelectColumns();
+        Hashtable aliases = criteria.getAsColumns();
         StringStackBuffer modifiers = criteria.getSelectModifiers();
 
         for (int i=0; i<modifiers.size(); i++)
@@ -2005,6 +2015,13 @@
         }
 
         
+        Iterator it = aliases.keySet().iterator();
+        while(it.hasNext())
+        {
+          String key = (String)it.next();
+          selectClause.add((String)aliases.get(key) + " AS " + key);
+        }
+
         Enumeration e = criteria.keys();
         while (e.hasMoreElements())
         {
-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

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


Re: [PATCH] adding AS columns to a Peer

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/11/01 3:58 AM, "Henning P. Schmiedehausen" <ma...@hometree.net>
wrote:

> +    Iterator it = aliases.keySet().iterator();
> +    while(it.hasNext())
> +    {
> +      String key = (String)it.next();
> +      selectClause.add((String)aliases.get(key) + " AS " + key);
> +    }
> +

Henning,

No tabs please. :-)

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


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