db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1231667 [3/4] - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/criteria/ torque-runtime/src/main/java/org/apache/torque/sql/ torque-runtime/src/main/java/org/apache/torque/util/ torque-templates/src/main/resour...
Date Sun, 15 Jan 2012 14:00:19 GMT
Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm Sun Jan 15 14:00:18 2012
@@ -73,12 +73,12 @@
   #else
         if ($field == null)
         {
-            $field = ${getter}(new Criteria(10));
+            $field = ${getter}(new Criteria());
         }
   #end
         return $field;
 #else
-        return ${getter}(new Criteria(10));
+        return ${getter}(new Criteria());
 #end
     }
 
@@ -166,11 +166,11 @@
 #if ($objectIsCaching)
         if ($field == null)
         {
-            $field = ${getter}(new Criteria(10), con);
+            $field = ${getter}(new Criteria(), con);
         }
         return $field;
 #else
-        return ${getter}(new Criteria(10), con);
+        return ${getter}(new Criteria(), con);
 #end
     }
 

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm Sun Jan 15 14:00:18 2012
@@ -46,6 +46,7 @@ import org.apache.torque.Column;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.TorqueRuntimeException;
+import $torqueGen.option("torque.om.criteriaClass");
 import org.apache.torque.map.TableMap;
 import org.apache.torque.om.mapper.RecordMapper;
 import org.apache.torque.om.mapper.CompositeMapper;
@@ -55,7 +56,6 @@ import org.apache.torque.om.StringKey;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.SimpleKey;
 import org.apache.torque.util.BasePeer;
-import org.apache.torque.util.Criteria;
 import org.apache.torque.util.Transaction;
 import org.apache.torque.util.ColumnValues;
 import org.apache.torque.util.JdbcTypedValue;

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm Sun Jan 15 14:00:18 2012
@@ -75,7 +75,7 @@
     #set ( $i = 0 )
     #foreach ($primaryKeyColumnElement in $primaryKeyColumnElements)
       #set ( $peerColumnName = $primaryKeyColumnElement.getAttribute("peerColumnName"))
-                Criteria.Criterion c$i = criteria.getNewCriterion(
+                Criterion c$i = criteria.getNewCriterion(
                     ${peerClassName}.$peerColumnName, keys[$i], Criteria.EQUAL);
       #set ( $j = $i - 1 )
       #if ($i > 0)

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm Sun Jan 15 14:00:18 2012
@@ -78,7 +78,7 @@
 
         setDbName(criteria);
 
-        return doDelete(criteria, ${peerClassName}.TABLE_NAME, con);
+        return doDelete(criteria, getTableMap(), con);
      }
 
     /**
@@ -97,7 +97,7 @@
 #if ($primaryKeyColumnElements.size() > 0)
         return doDelete(buildCriteria(obj.getPrimaryKey()));
 #else
-        return doDelete(buildSelectCriteria(obj));
+        return doDelete(buildSelectCriteria(obj), getTableMap());
 #end
     }
 
@@ -118,9 +118,9 @@
         throws TorqueException
     {
 #if ($primaryKeyColumnElements.size() > 0)
-        return doDelete(buildCriteria(obj.getPrimaryKey()), con);
+        return doDelete(buildCriteria(obj.getPrimaryKey()), getTableMap(), con);
 #else
-        return doDelete(buildSelectCriteria(obj), con);
+        return doDelete(buildSelectCriteria(obj), getTableMap(), con);
 #end
     }
 
@@ -139,7 +139,7 @@
     public int doDelete(Collection<${dbObjectClassName}> objects)
             throws TorqueException
     {
-        return doDelete(buildPkCriteria(objects));
+        return doDelete(buildPkCriteria(objects), getTableMap());
     }
 
     /**
@@ -162,7 +162,7 @@
             Connection con)
         throws TorqueException
     {
-        return doDelete(buildPkCriteria(objects), con);
+        return doDelete(buildPkCriteria(objects), getTableMap(), con);
     }
 
     /**
@@ -213,6 +213,6 @@
     public int doDelete(ObjectKey pk, Connection con)
         throws TorqueException
     {
-        return doDelete(buildCriteria(pk), con);
+        return doDelete(buildCriteria(pk), getTableMap(), con);
     }
 #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm Sun Jan 15 14:00:18 2012
@@ -77,7 +77,7 @@
         throws TorqueException
     {
         Criteria selectCriteria 
-                = new Criteria(${peerClassName}.DATABASE_NAME, 2);
+                = new Criteria(${peerClassName}.DATABASE_NAME);
         correctBooleans(columnValues);
 
 #foreach ($columnElement in $torqueGen.getChildren("column"))
@@ -85,7 +85,7 @@
   #if($columnElement.getAttribute("primaryKey") == "true")
     #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") )
     
-        selectCriteria.put(
+        selectCriteria.where(
                 ${peerClassName}.${peerColumnName},
                 columnValues.remove(${peerClassName}.${peerColumnName}).getValue());
   #end

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm Sun Jan 15 14:00:18 2012
@@ -137,7 +137,7 @@
     #foreach ($referenceElement in $foreignKeyReferences)
     #set ( $columnElement = $referenceElement.getChild("foreign-column").getChild("column") )
       #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
-                    Criteria.Criterion c$i = criteria.getNewCriterion(
+                    Criterion c$i = criteria.getNewCriterion(
                         ${foreignTablePeerClassName}.${peerColumnName}, keys[$i], Criteria.EQUAL);
       #set ( $j = $i - 1 )
       #if ($i > 0)

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm Sun Jan 15 14:00:18 2012
@@ -147,7 +147,7 @@
   #foreach ($referenceElement in $foreignKeyReferences)
   #set ( $columnElement = $referenceElement.getChild("local-column").getChild("column") )
     #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName"))
-                    Criteria.Criterion c$i = criteria.getNewCriterion(
+                    Criterion c$i = criteria.getNewCriterion(
                         ${foreignTablePeerClassName}.${peerColumnName}, keys[$i], Criteria.EQUAL);
     #set ( $j = $i - 1 )
     #if ($i > 0)

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm Sun Jan 15 14:00:18 2012
@@ -59,6 +59,8 @@ import org.apache.torque.TooManyRowsExce
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.TorqueRuntimeException;
+import $torqueGen.option("torque.om.criteriaClass");
+import $torqueGen.option("torque.om.criterionClass");
 import org.apache.torque.map.TableMap;
 import org.apache.torque.om.mapper.RecordMapper;
 import org.apache.torque.om.mapper.CompositeMapper;
@@ -69,7 +71,6 @@ import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.SimpleKey;
 import org.apache.torque.om.ComboKey;
 import org.apache.torque.util.BasePeer;
-import org.apache.torque.util.Criteria;
 import org.apache.torque.util.Transaction;
 import org.apache.torque.util.ColumnValues;
 import org.apache.torque.util.JdbcTypedValue;

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm Sun Jan 15 14:00:18 2012
@@ -124,7 +124,7 @@
             Connection con) throws TorqueException
     {
 
-        Criteria criteria = new Criteria(5);
+        Criteria criteria = new Criteria();
     #foreach ($columnElement in $primaryKeyColumnElements)
       #set ( $columnField = $columnElement.getAttribute("field") )
       #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") )

Modified: db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml Sun Jan 15 14:00:18 2012
@@ -202,7 +202,7 @@
   </table>
 
   <!-- TRQS263 -->
-  <table name="DATE_TEST" description="Table to test Date formats">
+  <table name="DATE_TIME_TIMESTAMP" description="Table to test Date formats">
     <column
       name="DATE_TEST_ID"
       required="true"

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java Sun Jan 15 14:00:18 2012
@@ -25,12 +25,14 @@ import junit.framework.TestCase;
 
 import org.apache.torque.adapter.DB;
 import org.apache.torque.adapter.DBMM;
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.map.TableMap;
 import org.apache.torque.om.mapper.StringMapper;
+import org.apache.torque.test.Author;
 import org.apache.torque.test.AuthorPeer;
+import org.apache.torque.test.Book;
 import org.apache.torque.test.BookPeer;
 import org.apache.torque.util.BasePeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Base functionality to be extended by all Torque test cases.  Test
@@ -53,6 +55,8 @@ public abstract class BaseRuntimeTestCas
         super(name);
     }
 
+    protected static DB defaultAdapter;
+
     /**
      * Initialize Torque on the first setUp().  Subclasses which override
      * setUp() must call super.setUp() as their first action.
@@ -68,6 +72,7 @@ public abstract class BaseRuntimeTestCas
                                 CONFIG_FILE_SYSTEM_PROPERTY));
             }
         }
+        defaultAdapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
     }
 
     /**
@@ -134,7 +139,33 @@ public abstract class BaseRuntimeTestCas
         Criteria criteria = new Criteria();
         BookPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         AuthorPeer.doDelete(criteria);
     }
+
+    /**
+     * Inserts test data into the bookstore tables.
+     *
+     * @throws TorqueException if filling data fails.
+     */
+    protected void insertBookstoreData() throws TorqueException
+    {
+        for (int i = 1; i <= 10; i++)
+        {
+            Author author = new Author();
+            author.setName("Author " + i);
+            author.save();
+            assertTrue("authorId should not be 0 after insert",
+                    author.getAuthorId() != 0);
+
+            for (int j = 1; j <= 10; j++)
+            {
+                Book book = new Book();
+                book.setAuthor(author);
+                book.setTitle("Book " + j + " - Author " + i);
+                book.setIsbn("ISBN" + j + "-" + i);
+                book.save();
+            }
+        }
+    }
 }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BeanTestConditional.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BeanTestConditional.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BeanTestConditional.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BeanTestConditional.java Sun Jan 15 14:00:18 2012
@@ -29,8 +29,6 @@ import org.apache.torque.test.Author;
 import org.apache.torque.test.AuthorPeer;
 import org.apache.torque.test.Book;
 import org.apache.torque.test.BookPeer;
-import org.apache.torque.test.bean.AuthorBean;
-import org.apache.torque.test.bean.BookBean;
 import org.apache.torque.util.Criteria;
 
 /**
@@ -87,7 +85,7 @@ public class BeanTestConditional extends
                 + " should be " + author.getAuthorId(),
                 author.getAuthorId() == authorBean.getAuthorId());
     }
-    
+
     /**
      * tests whether it is possible to serialize/deserialize beans
      * @throws Exception
@@ -99,7 +97,7 @@ public class BeanTestConditional extends
         author.setAuthorId(AUTHOR_1_ID);
 
         AuthorBean authorBean = author.getBean();
-        
+
         // serialize the AuthorBean
         byte[] serializedAuthorBean;
         {
@@ -107,12 +105,12 @@ public class BeanTestConditional extends
             ByteArrayOutputStream byteArrayOutputStream;
             try
             {
-                byteArrayOutputStream 
+                byteArrayOutputStream
                         = new ByteArrayOutputStream();
-                objectOutputStream 
+                objectOutputStream
                         = new ObjectOutputStream(byteArrayOutputStream);
                 objectOutputStream.writeObject(authorBean);
-                serializedAuthorBean 
+                serializedAuthorBean
                         = byteArrayOutputStream.toByteArray();
             }
             finally
@@ -130,11 +128,11 @@ public class BeanTestConditional extends
             ByteArrayInputStream byteArrayInputStream = null;
             try
             {
-                byteArrayInputStream 
+                byteArrayInputStream
                         = new ByteArrayInputStream(serializedAuthorBean);
-                objectInputStream 
+                objectInputStream
                         = new ObjectInputStream(byteArrayInputStream);
-                deserializedAuthorBean 
+                deserializedAuthorBean
                         = (AuthorBean) objectInputStream.readObject();
             }
             finally
@@ -179,7 +177,7 @@ public class BeanTestConditional extends
                 bookBean.getAuthorBean() == authorBean);
 
         author = Author.createAuthor(authorBean);
-        book = (Book) author.getBooks().get(0);
+        book = author.getBooks().get(0);
 
         assertTrue("author from book should be the same object as author "
                 + "after creating from bean",
@@ -243,7 +241,7 @@ public class BeanTestConditional extends
                 bookBean.getAuthorBean() != authorBean);
 
         author = Author.createAuthor(authorBean);
-        book = (Book) author.getBooks().get(0);
+        book = author.getBooks().get(0);
 
         assertTrue("author from book should not be the same object as author "
                 + "after creating from bean",

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java Sun Jan 15 14:00:18 2012
@@ -21,11 +21,8 @@ package org.apache.torque;
 
 import java.sql.Connection;
 import java.sql.ResultSet;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -40,6 +37,8 @@ import org.apache.torque.adapter.DBHsqld
 import org.apache.torque.adapter.DBMM;
 import org.apache.torque.adapter.DBMSSQL;
 import org.apache.torque.adapter.DBOracle;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.criteria.Criterion;
 import org.apache.torque.om.StringKey;
 import org.apache.torque.om.mapper.CompositeMapper;
 import org.apache.torque.om.mapper.IntegerMapper;
@@ -66,8 +65,6 @@ import org.apache.torque.test.C;
 import org.apache.torque.test.CPeer;
 import org.apache.torque.test.ClobTest;
 import org.apache.torque.test.ClobTestPeer;
-import org.apache.torque.test.DateTest;
-import org.apache.torque.test.DateTestPeer;
 import org.apache.torque.test.IfcTable;
 import org.apache.torque.test.IfcTable2;
 import org.apache.torque.test.IfcTable2Peer;
@@ -100,7 +97,6 @@ import org.apache.torque.test.RAb;
 import org.apache.torque.test.RAbPeer;
 import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.CountHelper;
-import org.apache.torque.util.Criteria;
 import org.apache.torque.util.Transaction;
 
 /**
@@ -253,7 +249,7 @@ public class DataTest extends BaseRuntim
         }
 
         Criteria crit = new Criteria();
-        Criteria.Criterion c = crit.getNewCriterion(BookPeer.TITLE,
+        Criterion c = crit.getNewCriterion(BookPeer.TITLE,
                 "Book 6 - Author 1", Criteria.GREATER_EQUAL);
         c.and(crit.getNewCriterion(BookPeer.TITLE,
                 "Book 8 - Author 3", Criteria.LESS_EQUAL));
@@ -272,7 +268,7 @@ public class DataTest extends BaseRuntim
         }
 
         // Test limit of zero works
-        crit.clear();
+        crit = new Criteria();
         crit.setLimit(0);
         try
         {
@@ -322,7 +318,7 @@ public class DataTest extends BaseRuntim
         assertTrue("List should have 1 books, not " + books.size(),
                 books.size() == 1);
 
-        criteria.clear();
+        criteria = new Criteria();
         criteria.setSingleRecord(true);
         criteria.setLimit(2);
         try
@@ -362,7 +358,7 @@ public class DataTest extends BaseRuntim
         nvt.save();
 
         // do check for comparison NOT_EQUAL and value null
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(
                 NullValueTablePeer.TEXT1,
                 (Integer)null,
@@ -384,7 +380,7 @@ public class DataTest extends BaseRuntim
                 "text");
 
         // do check for comparison EQUAL and value null
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(
                 NullValueTablePeer.TEXT1,
                 (Integer)null,
@@ -548,7 +544,7 @@ public class DataTest extends BaseRuntim
                 + bitTest.getBitValue(), bitTest.getBitValue());
 
         // query data
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(BitTestPeer.BIT_VALUE, new Boolean(true));
         List bitTestList = BitTestPeer.doSelect(criteria);
         assertTrue("Should have read 1 dataset "
@@ -561,7 +557,7 @@ public class DataTest extends BaseRuntim
                 + bitTest.getId().trim(),
                 "t1".equals(bitTest.getId().trim()));
 
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(BitTestPeer.BIT_VALUE, new Boolean(false));
         bitTestList = BitTestPeer.doSelect(criteria);
         assertTrue("Should have read 1 dataset "
@@ -595,7 +591,7 @@ public class DataTest extends BaseRuntim
                 + booleanCheck.getTestKey().trim(),
                 "t1".equals(booleanCheck.getTestKey().trim()));
 
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(BooleanCheckPeer.BCHAR_VALUE, new Boolean(false));
         criteria.add(BooleanCheckPeer.BINT_VALUE, new Boolean(false));
         booleanCheckList = BooleanCheckPeer.doSelect(criteria);
@@ -609,7 +605,7 @@ public class DataTest extends BaseRuntim
 
         // checks whether booleanint and booleanchar values are also
         // replaced in joined tables
-        criteria.clear();
+        criteria = new Criteria();
         criteria.addAlias("bc", BooleanCheckPeer.TABLE_NAME);
         criteria.addJoin(
                 BooleanCheckPeer.TEST_KEY,
@@ -627,12 +623,12 @@ public class DataTest extends BaseRuntim
 
         // check whether complex criteria are overwritten by
         // replaceBooleans
-        criteria.clear();
-        Criteria.Criterion criterion1 = criteria.getNewCriterion(
+        criteria = new Criteria();
+        Criterion criterion1 = criteria.getNewCriterion(
                 BooleanCheckPeer.BCHAR_VALUE,
                 Boolean.FALSE,
                 Criteria.EQUAL);
-        Criteria.Criterion criterion2 = criteria.getNewCriterion(
+        Criterion criterion2 = criteria.getNewCriterion(
                 BooleanCheckPeer.BCHAR_VALUE,
                 null,
                 Criteria.ISNULL);
@@ -647,7 +643,7 @@ public class DataTest extends BaseRuntim
 
         // check whether complex criteria are overwritten by
         // replaceBooleans
-        criteria.clear();
+        criteria = new Criteria();
         criterion1 = criteria.getNewCriterion(
                 BooleanCheckPeer.BCHAR_VALUE,
                 null,
@@ -669,21 +665,21 @@ public class DataTest extends BaseRuntim
                 "f1".equals(booleanCheck.getTestKey().trim()));
 
         // check whether booleans are replaced with unqualified columns
-        criteria.clear();
-        criteria.add("BooleanCheck.bint_value", true);
-        criteria.add("BooleanCheck.bchar_value", true);
+        criteria = new Criteria()
+            .where("BooleanCheck.bint_value", true)
+            .and("BooleanCheck.bchar_value", true);
 
         BooleanCheckPeer.correctBooleans(criteria);
 
-        Criteria.Criterion criterionInt
-                = criteria.getCriterion("BooleanCheck.bint_value");
+        Criterion criterionInt
+                = criteria.getTopLevelCriterion().getParts().get(0);
         Object intValue = criterionInt.getValue();
 
         assertTrue("The boolean value should be an instance of Integer",
                 intValue instanceof Integer);
 
-        Criteria.Criterion criterionChar = criteria.getCriterion(
-                "BooleanCheck.bchar_value");
+        Criterion criterionChar
+                = criteria.getTopLevelCriterion().getParts().get(1);
         Object charValue = criterionChar.getValue();
 
         assertTrue("The boolean value should be an instance of String",
@@ -691,21 +687,21 @@ public class DataTest extends BaseRuntim
 
         // check whether booleans are left alone with unqualified columns and
         // no table map
-        criteria.clear();
-        criteria.add("BooleanCheck.bint_value", true);
-        criteria.add("BooleanCheck.bchar_value", true);
+        criteria = new Criteria()
+            .where("BooleanCheck.bint_value", true)
+            .and("BooleanCheck.bchar_value", true);
 
         BasePeer.correctBooleans(criteria, null);
 
-        Criteria.Criterion criterionBool1 = criteria.getCriterion(
-                "BooleanCheck.bint_value");
+        Criterion criterionBool1
+                = criteria.getTopLevelCriterion().getParts().get(0);
         Object boolValue1 = criterionBool1.getValue();
 
         assertTrue("The boolean value should be an instance of Boolean",
                boolValue1 instanceof Boolean);
 
-        Criteria.Criterion criterionBool2 = criteria.getCriterion(
-                "BooleanCheck.bchar_value");
+        Criterion criterionBool2
+                = criteria.getTopLevelCriterion().getParts().get(1);
         Object boolValue2 = criterionBool2.getValue();
 
         assertTrue("The boolean value should be an instance of Boolean",
@@ -744,7 +740,7 @@ public class DataTest extends BaseRuntim
         author.setName("NewName");
         author.save();
 
-        criteria.clear();
+        criteria = new Criteria();
         criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
 
         authors = AuthorPeer.doSelect(criteria);
@@ -762,7 +758,7 @@ public class DataTest extends BaseRuntim
         AuthorPeer.doUpdate(author);
         Transaction.commit(connection);
 
-        criteria.clear();
+        criteria = new Criteria();
         criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
 
         authors = AuthorPeer.doSelect(criteria);
@@ -777,7 +773,7 @@ public class DataTest extends BaseRuntim
         author.setName("NewName3");
         AuthorPeer.doUpdate(author);
 
-        criteria.clear();
+        criteria = new Criteria();
         criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
 
         authors = AuthorPeer.doSelect(criteria);
@@ -1321,12 +1317,12 @@ public class DataTest extends BaseRuntim
 
         // Test ignore case in criterion
         criteria = new Criteria();
-        Criteria.Criterion criterion1 = criteria.getNewCriterion(
+        Criterion criterion1 = criteria.getNewCriterion(
                 AuthorPeer.NAME,
                 author.getName().toLowerCase(),
                 Criteria.EQUAL);
         criterion1.setIgnoreCase(true);
-        Criteria.Criterion criterion2 = criteria.getNewCriterion(
+        Criterion criterion2 = criteria.getNewCriterion(
                 AuthorPeer.AUTHOR_ID, null, Criteria.NOT_EQUAL);
         criterion1.and(criterion2);
 
@@ -1455,7 +1451,7 @@ public class DataTest extends BaseRuntim
         author.save();
 
         // check ignoreCase in Criteria
-        criteria.clear();
+        criteria = new Criteria();
         criteria.setIgnoreCase(true);
         criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
         result = AuthorPeer.doSelect(criteria);
@@ -1467,7 +1463,7 @@ public class DataTest extends BaseRuntim
         assertEquals(result.get(3).getName(), "BB");
 
         // check ignoreCase in orderBy
-        criteria.clear();
+        criteria = new Criteria();
         criteria.addAscendingOrderByColumn(AuthorPeer.NAME, true);
         result = AuthorPeer.doSelect(criteria);
         assertTrue("Size of result is not 4, but " + result.size(),
@@ -1539,105 +1535,6 @@ public class DataTest extends BaseRuntim
     }
 
     /**
-     * Tests the date, time and datetime accuracy.
-     * At the moment, no upper limit for the accuracy is checked,
-     * the differences are printed to stdout.
-     * @throws Exception if the test fails
-     */
-    public void testDateTime() throws Exception
-    {
-        // clean Date table
-        Criteria criteria = new Criteria();
-        criteria.add(
-                DateTestPeer.DATE_TEST_ID,
-                (Long) null,
-                Criteria.NOT_EQUAL);
-        DateTestPeer.doDelete(criteria);
-
-        // insert new DateTest object to db
-        DateTest dateTest = new DateTest();
-        Date now = new Date();
-        dateTest.setDateValue(now);
-        dateTest.setTimeValue(now);
-        dateTest.setTimestampValue(now);
-        dateTest.save();
-        DateFormat dateFormat = new SimpleDateFormat();
-        System.out.println(
-                "testDateTime() : set date to : "
-                + dateFormat.format(now));
-
-        // reload dateTest from db
-        DateTest loadedDateTest
-                = DateTestPeer.retrieveByPK(dateTest.getPrimaryKey());
-
-        System.out.println(
-                "testDateTime() : retrieved date : "
-                + dateFormat.format(loadedDateTest.getDateValue()));
-        System.out.println(
-                "testDateTime() : retrieved time : "
-                + dateFormat.format(loadedDateTest.getTimeValue()));
-        System.out.println(
-                "testDateTime() : retrieved timestamp : "
-                + dateFormat.format(loadedDateTest.getTimestampValue()));
-
-        // compute time differences between reloaded and original object
-        // TODO asserts rather than System.out.println!
-        long dateDifference
-                = dateTest.getDateValue().getTime()
-                    - loadedDateTest.getDateValue().getTime();
-        long timeDifference
-                = dateTest.getTimeValue().getTime()
-                    - loadedDateTest.getTimeValue().getTime();
-        long timestampDifference
-                = dateTest.getTimestampValue().getTime()
-                    - loadedDateTest.getTimestampValue().getTime();
-
-        System.out.println(
-                "testDateTime() : Date difference (ms): "
-                + dateDifference);
-        System.out.println(
-                "testDateTime() : Time difference (ms): "
-                + timeDifference);
-        System.out.println(
-                "testDateTime() : Timestamp difference (ms): "
-                + timestampDifference);
-    }
-
-    /**
-     * Checks that Criteria.CURRENT_DATE and Criteria.CURRENT_TIME work
-     * (i.e. do not throw an exception).
-     * Other behaviour is difficult to test as database implementations differ.
-     *
-     * @throws TorqueException if a problem occurs.
-     */
-    public void testCurrentDate() throws TorqueException
-    {
-        DB adapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
-        if (adapter instanceof DBMSSQL)
-        {
-            log.warn("testCurrentDate(): "
-                    + Criteria.CURRENT_DATE
-                    + " and "
-                    + Criteria.CURRENT_TIME
-                    + "are not supported by MSSQL");
-            return;
-        }
-        Criteria c = new Criteria();
-        c.add(DateTestPeer.DATE_VALUE, Criteria.CURRENT_DATE);
-        if (adapter instanceof DBOracle)
-        {
-            log.warn("testCurrentDate(): "
-                    + Criteria.CURRENT_TIME
-                    + "is not supported by Oracle");
-        }
-        else
-        {
-            c.add(DateTestPeer.TIME_VALUE, Criteria.CURRENT_TIME);
-        }
-        List<DateTest> result = DateTestPeer.doSelect(c);
-    }
-
-    /**
      * tests whether large primary keys are inserted and read correctly
      * @throws Exception if the test fails
      */
@@ -2456,7 +2353,7 @@ public class DataTest extends BaseRuntim
 
         Criteria criteria = new Criteria();
         criteria.add(AuthorPeer.AUTHOR_ID, (Object) null, Criteria.NOT_EQUAL);
-        criteria.add("name", (Object) "Joshua Bloch", Criteria.EQUAL);
+        criteria.add("name", "Joshua Bloch", Criteria.EQUAL);
         List<Author> authors = AuthorPeer.doSelect(criteria);
         assertEquals(1, authors.size());
     }
@@ -2575,15 +2472,15 @@ public class DataTest extends BaseRuntim
         // check that the escape clause (where needed) also works
         // with limit, offset and order by
         criteria = new Criteria();
-        Criteria.Criterion criterion1 = criteria.getNewCriterion(
+        Criterion criterion1 = criteria.getNewCriterion(
                 AuthorPeer.NAME,
                 "b%",
                 Criteria.LIKE);
-        Criteria.Criterion criterion2 = criteria.getNewCriterion(
+        Criterion criterion2 = criteria.getNewCriterion(
                 AuthorPeer.NAME,
                 "a\\%%",
                 Criteria.LIKE);
-        Criteria.Criterion criterion3 = criteria.getNewCriterion(
+        Criterion criterion3 = criteria.getNewCriterion(
                 AuthorPeer.NAME,
                 "cbc",
                 Criteria.LIKE);
@@ -2614,18 +2511,18 @@ public class DataTest extends BaseRuntim
         CPeer.doDelete(criteria);
 
         // clean R_AB table
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(RAbPeer.A_ID, (Long) null, Criteria.NOT_EQUAL);
         criteria.add(RAbPeer.B_ID, (Long) null, Criteria.NOT_EQUAL);
         RAbPeer.doDelete(criteria);
 
         // clean A table
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(APeer.A_ID, (Long) null, Criteria.NOT_EQUAL);
         APeer.doDelete(criteria);
 
         // clean B table
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(BPeer.B_ID, (Long) null, Criteria.NOT_EQUAL);
         BPeer.doDelete(criteria);
     }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DocsTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DocsTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DocsTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DocsTest.java Sun Jan 15 14:00:18 2012
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.adapter.DB;
 import org.apache.torque.adapter.DBMM;
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.map.TableMap;
 import org.apache.torque.om.mapper.ObjectListMapper;
 import org.apache.torque.test.Author;
@@ -32,7 +33,6 @@ import org.apache.torque.test.AuthorPeer
 import org.apache.torque.test.Book;
 import org.apache.torque.test.BookPeer;
 import org.apache.torque.util.BasePeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Runtime tests to make sure that the code which is supplied
@@ -89,7 +89,7 @@ public class DocsTest extends BaseRuntim
                      + e.getClass().getName()
                      + " : " + e.getMessage());
         }
-        criteria.clear();
+        criteria = new Criteria();
         criteria.add(
                 AuthorPeer.AUTHOR_ID,
                 (Long) null, Criteria.NOT_EQUAL);
@@ -373,8 +373,8 @@ public class DocsTest extends BaseRuntim
             + author.getName(),
             AUTHOR_2_NAME.equals(author.getName()));
     }
-    
-    
+
+
     /**
      * Criteria Howto, section "subselects"
      */
@@ -394,10 +394,10 @@ public class DocsTest extends BaseRuntim
         }
         Criteria subquery = new Criteria();
         subquery.addSelectColumn("MAX(" + AuthorPeer.AUTHOR_ID + ")");
-    
+
         Criteria criteria = new Criteria();
         criteria.add(AuthorPeer.AUTHOR_ID, subquery);
-    
+
         List<Author> authors = AuthorPeer.doSelect(criteria);
         assertEquals("Expected list of size 1 but got " + authors.size(),
                 1,

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java Sun Jan 15 14:00:18 2012
@@ -22,6 +22,7 @@ package org.apache.torque;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.test.CompIntegerVarcharFk;
 import org.apache.torque.test.CompIntegerVarcharFkPeer;
 import org.apache.torque.test.CompIntegerVarcharPk;
@@ -44,7 +45,6 @@ import org.apache.torque.test.RequiredOI
 import org.apache.torque.test.RequiredOIntegerFkPeer;
 import org.apache.torque.test.RequiredPIntegerFk;
 import org.apache.torque.test.RequiredPIntegerFkPeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Contains data (i.e. table records) for the tables in the foreign key schema.
@@ -577,34 +577,34 @@ public class ForeignKeySchemaData
         Criteria criteria = new Criteria();
         NullablePIntegerFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         RequiredPIntegerFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         NonPkPIntegerFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         NullableOIntegerFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         RequiredOIntegerFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         NonPkOIntegerFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         PIntegerPkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         OIntegerPkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         CompIntegerVarcharFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         CompNonpkFkPeer.doDelete(criteria);
 
-        criteria.clear();
+        criteria = new Criteria();
         CompIntegerVarcharPkPeer.doDelete(criteria);
     }
 }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/InitShutdownTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/InitShutdownTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/InitShutdownTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/InitShutdownTest.java Sun Jan 15 14:00:18 2012
@@ -23,6 +23,7 @@ import java.util.List;
 
 import junit.framework.TestCase;
 
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.test.NonPkOIntegerFkPeer;
 import org.apache.torque.test.NonPkPIntegerFkPeer;
 import org.apache.torque.test.NullableOIntegerFkPeer;
@@ -33,7 +34,6 @@ import org.apache.torque.test.PIntegerPk
 import org.apache.torque.test.PIntegerPkPeer;
 import org.apache.torque.test.RequiredOIntegerFkPeer;
 import org.apache.torque.test.RequiredPIntegerFkPeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Tests initialisation and shutdown of Torque.
@@ -121,11 +121,11 @@ public class InitShutdownTest extends Te
     {
         Criteria criteria = new Criteria();
         NullableOIntegerFkPeer.doDelete(criteria);
-        criteria.clear();
+        criteria = new Criteria();
         RequiredOIntegerFkPeer.doDelete(criteria);
-        criteria.clear();
+        criteria = new Criteria();
         NonPkOIntegerFkPeer.doDelete(criteria);
-        criteria.clear();
+        criteria = new Criteria();
         OIntegerPkPeer.doDelete(criteria);
 
         OIntegerPk oIntegerPk = new OIntegerPk();
@@ -147,11 +147,11 @@ public class InitShutdownTest extends Te
     {
         Criteria criteria = new Criteria();
         NullablePIntegerFkPeer.doDelete(criteria);
-        criteria.clear();
+        criteria = new Criteria();
         RequiredPIntegerFkPeer.doDelete(criteria);
-        criteria.clear();
+        criteria = new Criteria();
         NonPkPIntegerFkPeer.doDelete(criteria);
-        criteria.clear();
+        criteria = new Criteria();
         PIntegerPkPeer.doDelete(criteria);
 
         ForeignKeySchemaData.clearTablesInDatabase();

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/JndiConfigurationTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/JndiConfigurationTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/JndiConfigurationTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/JndiConfigurationTest.java Sun Jan 15 14:00:18 2012
@@ -38,18 +38,18 @@ import org.apache.commons.configuration.
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.dbcp.BasicDataSource;
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.dsfactory.AbstractDataSourceFactory;
 import org.apache.torque.dsfactory.DataSourceFactory;
 import org.apache.torque.dsfactory.JndiDataSourceFactory;
 import org.apache.torque.test.BookPeer;
-import org.apache.torque.util.Criteria;
 
 /**
- * Test for configuration using JNDI. The test assumes that we have a 
+ * Test for configuration using JNDI. The test assumes that we have a
  * non-jndi configuration, and creates the data source configuration from it.
  * It is tested whether we can bind a data source manually into jndi and
- * retrieve it in Torque, and also it is tested whether we can bind a 
- * data source using Torque. 
+ * retrieve it in Torque, and also it is tested whether we can bind a
+ * data source using Torque.
  * Note: This test does not extend BaseRuntimeTestCase as we do not want Torque
  * to be initialized.
  *
@@ -62,13 +62,13 @@ public class JndiConfigurationTest exten
      * The subcontext where the data source is bound.
      */
     protected static final String JNDI_SUBCONTEXT = "jdbc";
-    
+
     /**
      * the full jndi path to the data source.
      */
-    protected static final String JNDI_PATH 
+    protected static final String JNDI_PATH
             = JNDI_SUBCONTEXT + "/" + "jndiTestDataSource";
-    
+
     /**
      * Creates a new instance.
      */
@@ -82,7 +82,7 @@ public class JndiConfigurationTest exten
         // super.setUp() initializes torque, but here we want to
         // do that ourselves
     }
-    
+
     /**
      * Tests whether our home-made Data Source works.
      * @throws Exception if the test fails.
@@ -103,9 +103,9 @@ public class JndiConfigurationTest exten
             }
         }
     }
-    
+
     /**
-     * Binds a DataSource to the jndi and checks that we have successfully 
+     * Binds a DataSource to the jndi and checks that we have successfully
      * bound it. Then Torque is configured to lookup the DataSource in jndi,
      * and it is checked if Torque can read from the database. Finally,
      * the DataSource is closed and unbound.
@@ -116,7 +116,7 @@ public class JndiConfigurationTest exten
         // compose the correct configuration
         Configuration torqueConfiguration = getTorqueConfiguraton();
         String defaultDatabase = getDefaultDatabase(torqueConfiguration);
-        
+
         // remove the dsfactory configuration from the configuration
         {
             Configuration dsfactoryConfiguration = torqueConfiguration.subset(
@@ -125,7 +125,7 @@ public class JndiConfigurationTest exten
                     + defaultDatabase);
             dsfactoryConfiguration.clear();
         }
-        
+
         // add the jndi configuration to the configuration
         torqueConfiguration.setProperty(
                 Torque.TORQUE_KEY + "."
@@ -145,9 +145,9 @@ public class JndiConfigurationTest exten
                 + DataSourceFactory.DSFACTORY_KEY + "."
                 + defaultDatabase + "."
                 + JndiDataSourceFactory.JNDI_KEY + "."
-                + Context.INITIAL_CONTEXT_FACTORY, 
+                + Context.INITIAL_CONTEXT_FACTORY,
                 org.apache.naming.java.javaURLContextFactory.class.getName());
-        
+
         //System.out.println("Configuration for testExternalBindTorqueLookup:");
         //debugConfiguration(torqueConfiguration);
         //System.out.println();
@@ -158,13 +158,13 @@ public class JndiConfigurationTest exten
             bindDataSource();
             BasicDataSource dataSource = retrieveDataSource();
             dataSourceConnect(dataSource);
-            
+
 
             if (Torque.isInit())
             {
                 Torque.shutdown();
             }
-            // initialize torque with the created configuration 
+            // initialize torque with the created configuration
             // and check that we can connect to the database.
             try
             {
@@ -181,9 +181,9 @@ public class JndiConfigurationTest exten
             unbindDataSource();
         }
     }
-    
+
     /**
-     * Binds a DataSource to the jndi and checks that we have successfully 
+     * Binds a DataSource to the jndi and checks that we have successfully
      * bound it. Then Torque is configured to lookup the DataSource in jndi,
      * and it is checked if Torque can read from the database. Finally,
      * the DataSource is closed and unbound.
@@ -194,7 +194,7 @@ public class JndiConfigurationTest exten
         // compose the correct configuration
         Configuration torqueConfiguration = getTorqueConfiguraton();
         String defaultDatabase = getDefaultDatabase(torqueConfiguration);
-        
+
         // add the jndi configuration to the configuration
         torqueConfiguration.setProperty(
                 Torque.TORQUE_KEY + "."
@@ -214,20 +214,20 @@ public class JndiConfigurationTest exten
                 + DataSourceFactory.DSFACTORY_KEY + "."
                 + defaultDatabase + "."
                 + JndiDataSourceFactory.JNDI_KEY + "."
-                + Context.INITIAL_CONTEXT_FACTORY, 
+                + Context.INITIAL_CONTEXT_FACTORY,
                 org.apache.naming.java.javaURLContextFactory.class.getName());
-        
+
         // add the datasource configuration
         torqueConfiguration.setProperty(
                 Torque.TORQUE_KEY + "."
                 + DataSourceFactory.DSFACTORY_KEY + "."
                 + defaultDatabase + "."
                 + JndiDataSourceFactory.DATASOURCE_KEY + "."
-                + JndiDataSourceFactory.CLASSNAME_KEY, 
+                + JndiDataSourceFactory.CLASSNAME_KEY,
                 BasicDataSource.class.getName());
         {
             Map tempStore = new HashMap();
-            Configuration connectionConfiguration 
+            Configuration connectionConfiguration
                     = torqueConfiguration.subset(
                         Torque.TORQUE_KEY + "."
                         + DataSourceFactory.DSFACTORY_KEY + "."
@@ -238,7 +238,7 @@ public class JndiConfigurationTest exten
             {
                 String key = (String) keyIt.next();
                 String value = connectionConfiguration.getString(key);
-                
+
                 if ("user".equals(key))
                 {
                     // setUser() in SharedPoolDataSouce corresponds to
@@ -256,21 +256,21 @@ public class JndiConfigurationTest exten
                         + DataSourceFactory.DSFACTORY_KEY + "."
                         + defaultDatabase + "."
                         + JndiDataSourceFactory.DATASOURCE_KEY + "."
-                        + key, 
+                        + key,
                         value);
             }
             // add the new keys
-            for (Iterator keyIt = tempStore.keySet().iterator(); 
+            for (Iterator keyIt = tempStore.keySet().iterator();
                 keyIt.hasNext(); )
             {
                 String key = (String) keyIt.next();
                 String value = (String) tempStore.get(key);
                 torqueConfiguration.setProperty(key, value);
             }
-            
+
             // remove the configuration for the original datasource
             connectionConfiguration.clear();
-            Configuration poolConfiguration 
+            Configuration poolConfiguration
                 = torqueConfiguration.subset(
                         Torque.TORQUE_KEY + "."
                         + DataSourceFactory.DSFACTORY_KEY + "."
@@ -278,14 +278,14 @@ public class JndiConfigurationTest exten
                         + AbstractDataSourceFactory.POOL_KEY);
             poolConfiguration.clear();
         }
-        
+
         //System.out.println("Configuration for testTorqueBindTorqueLookup:");
         //debugConfiguration(torqueConfiguration);
         //System.out.println();
-        
+
         try
         {
-            // initialize torque with the created configuration 
+            // initialize torque with the created configuration
             // and check that we can connect to the database.
             try
             {
@@ -302,7 +302,7 @@ public class JndiConfigurationTest exten
             unbindDataSource();
         }
     }
-    
+
     /**
      * creates and binds a BasicDataSource into jndi.
      * @throws Exception if DataSource creation or binding fails.
@@ -314,7 +314,7 @@ public class JndiConfigurationTest exten
         context.createSubcontext(JNDI_SUBCONTEXT);
         context.bind(JNDI_PATH, dataSource);
     }
-    
+
     /**
      * Retrieves a BasicDataSource from jndi.
      * @throws Exception if the jndi lookup fails or no DataSource is bound.
@@ -322,7 +322,7 @@ public class JndiConfigurationTest exten
     protected BasicDataSource retrieveDataSource() throws Exception
     {
         Context context = getInitialContext();
-        BasicDataSource dataSource 
+        BasicDataSource dataSource
                 = (BasicDataSource) context.lookup(JNDI_PATH);
 
         if (dataSource == null)
@@ -331,7 +331,7 @@ public class JndiConfigurationTest exten
         }
         return dataSource;
     }
-        
+
     /**
      * unbinds and closes the BasicDataSource in jndi.
      * @throws Exception if creation or binfding fails.
@@ -339,7 +339,7 @@ public class JndiConfigurationTest exten
     protected void unbindDataSource() throws Exception
     {
         Context context = getInitialContext();
-        BasicDataSource dataSource 
+        BasicDataSource dataSource
                 = (BasicDataSource) context.lookup(JNDI_PATH);
 
         try
@@ -354,7 +354,7 @@ public class JndiConfigurationTest exten
             context.unbind(JNDI_PATH);
         }
     }
-    
+
     /**
      * Creates a Data Source from the Torque configuration without using Torque.
      * @return a SharedPoolDataSource source.
@@ -369,13 +369,13 @@ public class JndiConfigurationTest exten
                 + DataSourceFactory.DSFACTORY_KEY + "."
                 + defaultDatabase + "."
                 + AbstractDataSourceFactory.CONNECTION_KEY);
-        
+
         BasicDataSource dataSource = new BasicDataSource();
         for (Iterator i = dsfactoryConfiguration.getKeys(); i.hasNext();)
         {
             String key = (String) i.next();
             String stringValue = dsfactoryConfiguration.getString(key);
-            
+
             if ("user".equals(key))
             {
                 // setUser() in SharedPoolDataSouce corresponds to
@@ -388,14 +388,14 @@ public class JndiConfigurationTest exten
                 // setDriverClassName() in BasicDataSourceFactory
                 key = "driverClassName";
             }
-                
+
             Class propertyType =
                     PropertyUtils.getPropertyType(dataSource, key);
             Object value =
                     ConvertUtils.convert(stringValue, propertyType);
             PropertyUtils.setSimpleProperty(dataSource, key, value);
         }
-        
+
         return dataSource;
     }
 
@@ -443,30 +443,30 @@ public class JndiConfigurationTest exten
             }
         }
     }
-    
+
     /**
      * Retrieves (or creates if it does not exist) an InitialContext.
      * @return the InitialContext.
-     * @throws NamingException if the InitialContext cannot be retrieved 
+     * @throws NamingException if the InitialContext cannot be retrieved
      *         or created.
      */
     protected InitialContext getInitialContext() throws NamingException
     {
         Hashtable environment = new Hashtable();
         environment.put(
-                Context.INITIAL_CONTEXT_FACTORY, 
+                Context.INITIAL_CONTEXT_FACTORY,
                 org.apache.naming.java.javaURLContextFactory.class.getName());
         InitialContext context = new InitialContext(environment);
         return context;
     }
-    
+
     /**
      * Retrieves the path for Torque's configuration from the System Properties,
      * loads the configuration and returns it.
      * @return Torque's configuration.
      * @throws ConfigurationException if the configuration cannot be loaded.
      */
-    protected static Configuration getTorqueConfiguraton() 
+    protected static Configuration getTorqueConfiguraton()
             throws ConfigurationException
     {
         Configuration configuration = new PropertiesConfiguration(
@@ -476,7 +476,7 @@ public class JndiConfigurationTest exten
     }
 
     /**
-     * extraxts the default Database out of Torque's configuration. 
+     * extraxts the default Database out of Torque's configuration.
      * @param torqueConfiguration the Torque configuration
      * @return the default Data Source.
      */
@@ -489,7 +489,7 @@ public class JndiConfigurationTest exten
                 + Torque.DEFAULT_KEY);
         return defaultDatabase;
     }
-    
+
     /**
      * Prints the contents of the configuration to System.out
      * @param configuration the configuration to be debugged.
@@ -499,7 +499,7 @@ public class JndiConfigurationTest exten
         for (Iterator dsKeyIt = configuration.getKeys();
         dsKeyIt.hasNext(); )
         {
-            
+
             String key = (String) dsKeyIt.next();
             System.out.println(key + " = " + configuration.getString(key));
         }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java Sun Jan 15 14:00:18 2012
@@ -20,15 +20,8 @@ package org.apache.torque;
  */
 
 import org.apache.torque.test.Author;
-import org.apache.torque.test.manager.AuthorManager;
-import org.apache.torque.test.AuthorPeer;
 import org.apache.torque.test.Book;
-import org.apache.torque.test.manager.BookManager;
-import org.apache.torque.test.BookPeer;
 import org.apache.torque.test.IfcTable;
-import org.apache.torque.test.LocalTestInterface;
-import org.apache.torque.test.manager.TestInterfaceManager;
-import org.apache.torque.util.Criteria;
 
 /**
  * Runtime tests for managers and caching.
@@ -62,22 +55,22 @@ public class ManagerTestConditional exte
         Author author2 = new Author();
         author2.setName("author2");
         author2.save();
-        
+
         Author myauthor = AuthorManager.getCachedInstance(author1.getPrimaryKey());
         assertNotNull("Primary key of Author1 should not be null", author1.getPrimaryKey());
         assertNotNull("MyAuthor should not be null", myauthor);
         assertTrue("Author1 and MyAuthor should point to the same cache instance", author1 == myauthor);
-        
+
         Book book = new Book();
         book.setAuthor(author1);
         book.setTitle("Book 1");
         book.setIsbn("unknown");
         book.save();
-        
+
         Book mybook = BookManager.getInstance(book.getPrimaryKey());
         assertTrue("Author1 and the author of MyBook should point to the same cache instance", author1 == mybook.getAuthor());
     }
-    
+
     /**
      * Tests whether managers return the right interface
      * @throws Exception if the test fails
@@ -85,7 +78,7 @@ public class ManagerTestConditional exte
     public void testInterfaces() throws Exception
     {
         TestInterface ifc = TestInterfaceManager.getInstance();
-        
+
         assertTrue("TestInterfaceManager should create instances of TestInterface", ifc instanceof TestInterface);
         assertTrue("TestInterfaceManager should also create instances of IfcTable", ifc instanceof IfcTable);
     }

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/PkSchemaData.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/PkSchemaData.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/PkSchemaData.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/PkSchemaData.java Sun Jan 15 14:00:18 2012
@@ -22,9 +22,9 @@ package org.apache.torque;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.test.Nopk;
 import org.apache.torque.test.NopkPeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Contains data (i.e. table records) for the tables in the pk schema.
@@ -39,12 +39,12 @@ public class PkSchemaData
     /**
      * Creates the default Test data for the pk schema.
      * The test data is filled as follows (p=primitive, o=object):
-     * 
+     *
      * nopk1
      * nopk2
      * nopk3
-     *     
-     * 
+     *
+     *
      * @return a new instance filled with the default test data.
      *
      * @throws TorqueException should not occur.
@@ -96,7 +96,7 @@ public class PkSchemaData
             nopk.save();
         }
     }
-    
+
     /**
      * Deletes all records in the  pk schema's tables.
      *

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DateTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DateTest.java?rev=1231667&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DateTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DateTest.java Sun Jan 15 14:00:18 2012
@@ -0,0 +1,415 @@
+package org.apache.torque.generated.peer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.BaseRuntimeTestCase;
+import org.apache.torque.TorqueException;
+import org.apache.torque.adapter.DBMSSQL;
+import org.apache.torque.adapter.DBOracle;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.test.DateTimeTimestamp;
+import org.apache.torque.test.DateTimeTimestampPeer;
+
+/**
+ * Runtime tests.
+ *
+ * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
+ * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
+ * @author <a href="mailto:fischer@seitenbau.de">Thomas Fischer</a>
+ * @author <a href="mailto:patrick.carl@web.de">Patrick Carl</a>
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id: DataTest.java 1213056 2011-12-11 20:31:06Z tfischer $
+ */
+public class DateTest extends BaseRuntimeTestCase
+{
+    private static Log log = LogFactory.getLog(DateTest.class);
+
+    /**
+     * Creates a new instance.
+     */
+    public DateTest(String name)
+    {
+        super(name);
+    }
+
+    /**
+     * Tests the date behaviour. Date fields should be truncated to the start
+     * of day when saved and reloaded. Note that this does not tell
+     * anything about how the field is saved in the database, which can differ
+     * between databases.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testDateTime() throws Exception
+    {
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        Date now = new Date();
+        dateTimeTimestamp.setDateValue(now);
+        dateTimeTimestamp.setTimeValue(now);
+        dateTimeTimestamp.setTimestampValue(now);
+        dateTimeTimestamp.save();
+
+        // reload dateTest from db
+        DateTimeTimestamp loaded = DateTimeTimestampPeer.retrieveByPK(
+                dateTimeTimestamp.getPrimaryKey());
+
+        // calculate expected value
+        Date expected;
+//        if (adapter instanceof DBOracle)
+//        {
+//            expected = new Date(now.getTime() / 1000L * 1000L);
+//        }
+//        else
+        {
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(now);
+            calendar.set(Calendar.MILLISECOND, 0);
+            calendar.set(Calendar.SECOND, 0);
+            calendar.set(Calendar.MINUTE, 0);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+            expected = calendar.getTime();
+        }
+
+        // verify
+        assertEquals(expected, loaded.getDateValue());
+    }
+
+    /**
+     * Tests the time behaviour. Time fields should have the date set
+     * to 1.1.1970. Note that this does not tell
+     * anything about how the field is saved in the database, which can differ
+     * between databases.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testTime() throws Exception
+    {
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        Date now = new Date();
+        dateTimeTimestamp.setDateValue(now);
+        dateTimeTimestamp.setTimeValue(now);
+        dateTimeTimestamp.setTimestampValue(now);
+        dateTimeTimestamp.save();
+
+        // reload dateTest from db
+        DateTimeTimestamp loaded = DateTimeTimestampPeer.retrieveByPK(
+                dateTimeTimestamp.getPrimaryKey());
+
+        // calculate expected value
+        Date expected;
+//        if (adapter instanceof DBOracle)
+//        {
+//            expected = new Date(now.getTime() / 1000L * 1000L);
+//        }
+//        else
+        {
+            Calendar calendar = new GregorianCalendar();
+            calendar.setTime(now);
+            calendar.set(Calendar.DAY_OF_MONTH, 1);
+            calendar.set(Calendar.MONTH, Calendar.JANUARY);
+            calendar.set(Calendar.YEAR, 1970);
+            calendar.set(Calendar.MILLISECOND, 0);
+            expected = calendar.getTime();
+        }
+
+        // verify
+        long loadedTimestampRounded
+                = loaded.getTimeValue().getTime() / 1000L * 1000L;
+        assertEquals(expected, new Date(loadedTimestampRounded));
+    }
+
+    /**
+     * Tests the timestamp accuracy. Timestamp fields should have at least
+     * second accuracy.
+     *
+     * @throws Exception if the test fails
+     */
+    public void testTimestamp() throws Exception
+    {
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        Date now = new Date();
+        dateTimeTimestamp.setDateValue(now);
+        dateTimeTimestamp.setTimeValue(now);
+        dateTimeTimestamp.setTimestampValue(now);
+        dateTimeTimestamp.save();
+
+        // reload dateTest from db
+        DateTimeTimestamp loaded = DateTimeTimestampPeer.retrieveByPK(
+                dateTimeTimestamp.getPrimaryKey());
+
+        // calculate expected value
+        Date min = new Date(now.getTime() / 1000L * 1000L);;
+        Date max = new Date(min.getTime() + 999L);
+
+        // verify
+        DateFormat dateFormat = new SimpleDateFormat();
+        Date actual = loaded.getTimestampValue();
+        assertFalse(
+                "the loaded value " + dateFormat.format(actual)
+                    + " should not be after " + dateFormat.format(min),
+                min.after(actual));
+        assertFalse(
+                "the loaded value " + dateFormat.format(actual)
+                    + " should not be before " + dateFormat.format(max),
+                max.before(actual));
+    }
+
+    /**
+     * Checks that Criteria.CURRENT_DATE works (i.e. does not throw
+     * an exception).
+     * Other behaviour is difficult to test as database implementations differ.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testCurrentDate() throws TorqueException
+    {
+        if (defaultAdapter instanceof DBMSSQL)
+        {
+            log.warn("testCurrentDate(): "
+                    + Criteria.CURRENT_DATE
+                    + "is not supported by MSSQL");
+            return;
+        }
+        Criteria c = new Criteria().where(
+                DateTimeTimestampPeer.DATE_VALUE, Criteria.CURRENT_DATE);
+        DateTimeTimestampPeer.doSelect(c);
+    }
+
+    /**
+     * Checks that Criteria.CURRENT_TIME works (i.e. does not throw
+     * an exception).
+     * Other behaviour is difficult to test as database implementations differ.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testCurrentTime() throws TorqueException
+    {
+        if (defaultAdapter instanceof DBMSSQL
+                || defaultAdapter instanceof DBOracle)
+        {
+            log.warn("testCurrentTime(): "
+                    + Criteria.CURRENT_TIME
+                    + "is not supported by MSSQL and Oracle");
+            return;
+        }
+        Criteria c = new Criteria().where(
+                DateTimeTimestampPeer.TIME_VALUE, Criteria.CURRENT_TIME);
+        DateTimeTimestampPeer.doSelect(c);
+    }
+
+    /**
+     * Checks that a select is possible using a java.util.date object
+     * in a date field.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testSelectWithUtilDateOnDate() throws TorqueException
+    {
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        dateTimeTimestamp.setDateValue(
+                new GregorianCalendar(2010, 1, 23).getTime());
+        dateTimeTimestamp.setTimeValue(new Date());
+        dateTimeTimestamp.setTimestampValue(new Date());
+        dateTimeTimestamp.save();
+
+        // execute select
+        Criteria criteria = new Criteria();
+        criteria.where(DateTimeTimestampPeer.DATE_VALUE,
+                new GregorianCalendar(2010, 1, 23).getTime());
+        List<DateTimeTimestamp> result
+            = DateTimeTimestampPeer.doSelect(criteria);
+
+        // verify
+        assertEquals(1, result.size());
+        assertEquals(dateTimeTimestamp, result.get(0));
+    }
+
+    /**
+     * Checks that a select is possible using a java.util.date object
+     * in a time field.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testSelectWithUtilDateOnTime() throws TorqueException
+    {
+        if (defaultAdapter instanceof DBMSSQL)
+        {
+            log.warn("testSelectWithUtilDateOnTime(): "
+                    + "Selecting time with a date Object will not work on MSSQL"
+                    + " because time is 1900 based in MSSQL but 1970 based"
+                    + " in java");
+            return;
+        }
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        dateTimeTimestamp.setDateValue(new Date());
+        dateTimeTimestamp.setTimeValue(new Date(1234000));
+        dateTimeTimestamp.setTimestampValue(new Date());
+        dateTimeTimestamp.save();
+
+        // execute select
+        Criteria criteria = new Criteria();
+        criteria.where(DateTimeTimestampPeer.TIME_VALUE, new Date(1234000));
+        List<DateTimeTimestamp> result
+            = DateTimeTimestampPeer.doSelect(criteria);
+
+        // verify
+        assertEquals(1, result.size());
+        assertEquals(dateTimeTimestamp, result.get(0));
+    }
+
+    /**
+     * Checks that a select is possible using a java.sql.time object
+     * in a time field.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testSelectWithSqlTimeOnTime() throws TorqueException
+    {
+        if (defaultAdapter instanceof DBMSSQL)
+        {
+            log.warn("testSelectWithUtilDateOnTime(): "
+                    + "Selecting time with a time Object will not work on MSSQL"
+                    + " because time is 1900 based in MSSQL but 1970 based"
+                    + " in java");
+            return;
+        }
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        dateTimeTimestamp.setDateValue(new Date());
+        dateTimeTimestamp.setTimeValue(new Date(1234000));
+        dateTimeTimestamp.setTimestampValue(new Date());
+        dateTimeTimestamp.save();
+
+        // execute select
+        Criteria criteria = new Criteria();
+        criteria.where(
+                DateTimeTimestampPeer.TIME_VALUE,
+                new java.sql.Time(1234000));
+        List<DateTimeTimestamp> result
+            = DateTimeTimestampPeer.doSelect(criteria);
+
+        // verify
+        assertEquals(1, result.size());
+        assertEquals(dateTimeTimestamp, result.get(0));
+    }
+
+    /**
+     * Checks that a select is possible using a java.util.date object
+     * in a timestamp field.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testSelectWithUtilDateOnTimestamp() throws TorqueException
+    {
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        dateTimeTimestamp.setDateValue(new Date());
+        dateTimeTimestamp.setTimeValue(new Date());
+        dateTimeTimestamp.setTimestampValue(
+                new GregorianCalendar(2010, 1, 23).getTime());
+        dateTimeTimestamp.save();
+
+        // execute select
+        Criteria criteria = new Criteria();
+        criteria.where(DateTimeTimestampPeer.TIMESTAMP_VALUE,
+                new GregorianCalendar(2010, 1, 23).getTime());
+        List<DateTimeTimestamp> result
+            = DateTimeTimestampPeer.doSelect(criteria);
+
+        // verify
+        assertEquals(1, result.size());
+        assertEquals(dateTimeTimestamp, result.get(0));
+    }
+
+    /**
+     * Checks that a select is possible using a java.sql.timestamp object
+     * in a timestamp field.
+     *
+     * @throws TorqueException if a problem occurs.
+     */
+    public void testSelectWithSqlTimestampOnTimestamp() throws TorqueException
+    {
+        cleanDateTimeTimestampTable();
+
+        // insert new DateTest object to db
+        DateTimeTimestamp dateTimeTimestamp = new DateTimeTimestamp();
+        dateTimeTimestamp.setDateValue(new Date());
+        dateTimeTimestamp.setTimeValue(new Date());
+        dateTimeTimestamp.setTimestampValue(
+                new GregorianCalendar(2010, 1, 23).getTime());
+        dateTimeTimestamp.save();
+
+        // execute select
+        Criteria criteria = new Criteria();
+        Date toSelect = new GregorianCalendar(2010, 1, 23).getTime();
+        criteria.where(
+                DateTimeTimestampPeer.TIMESTAMP_VALUE,
+                new java.sql.Timestamp(toSelect.getTime()));
+        List<DateTimeTimestamp> result
+            = DateTimeTimestampPeer.doSelect(criteria);
+
+        // verify
+        assertEquals(1, result.size());
+        assertEquals(dateTimeTimestamp, result.get(0));
+    }
+
+    /**
+     * Cleans the DateTimeTimestamp table.
+     *
+     * @throws TorqueException if cleaning fails.
+     */
+    private void cleanDateTimeTimestampTable() throws TorqueException
+    {
+        Criteria criteria = new Criteria();
+        criteria.where(
+                DateTimeTimestampPeer.DATE_TEST_ID,
+                (Long) null,
+                Criteria.NOT_EQUAL);
+        DateTimeTimestampPeer.doDelete(criteria);
+    }
+}

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java Sun Jan 15 14:00:18 2012
@@ -29,6 +29,7 @@ import org.apache.torque.BaseRuntimeTest
 import org.apache.torque.ForeignKeySchemaData;
 import org.apache.torque.PkSchemaData;
 import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.criteria.SqlEnum;
 import org.apache.torque.om.NumberKey;
 import org.apache.torque.om.ObjectKey;
@@ -38,7 +39,6 @@ import org.apache.torque.test.NullableOI
 import org.apache.torque.test.NullableOIntegerFkPeer;
 import org.apache.torque.test.OIntegerPk;
 import org.apache.torque.test.OIntegerPkPeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Tests the delete methods in the generated Peer classes.

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java Sun Jan 15 14:00:18 2012
@@ -24,6 +24,7 @@ import java.util.List;
 import org.apache.torque.BaseRuntimeTestCase;
 import org.apache.torque.ForeignKeySchemaData;
 import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
 import org.apache.torque.test.CompIntegerVarcharFk;
 import org.apache.torque.test.CompIntegerVarcharFkPeer;
 import org.apache.torque.test.CompIntegerVarcharPk;
@@ -40,7 +41,6 @@ import org.apache.torque.test.PIntegerPk
 import org.apache.torque.test.PIntegerPkPeer;
 import org.apache.torque.test.RequiredPIntegerFk;
 import org.apache.torque.test.RequiredPIntegerFkPeer;
-import org.apache.torque.util.Criteria;
 
 /**
  * Tests the filler methods in the generated Peer classes.

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/DatabaseTools.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/DatabaseTools.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/DatabaseTools.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/DatabaseTools.java Sun Jan 15 14:00:18 2012
@@ -11,9 +11,9 @@ public class DatabaseTools
 {
     /**
      * Returns all table names available for this Connection.
-     * 
+     *
      * @param connection the database connection to.
-     * 
+     *
      * @return the table names in upper case.
      *
      * @throws SQLException if an error occurs.
@@ -32,15 +32,15 @@ public class DatabaseTools
         }
         return result;
     }
-    
+
     /**
      * Returns whether a table with the given name exists.
-     * 
+     *
      * @param connection the database connection to.
-     * @param name the name of the table to check. 
-     * 
+     * @param name the name of the table to check.
+     *
      * @return whether the table name exists.
-     *  
+     *
      * @throws SQLException if an error occurs.
      */
     public static boolean tableExists(String name, Connection connection)

Added: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java?rev=1231667&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java (added)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java Sun Jan 15 14:00:18 2012
@@ -0,0 +1,42 @@
+package org.apache.torque.util;
+
+import org.apache.torque.BaseRuntimeTestCase;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.test.BookPeer;
+
+/**
+ * Tests the methods in BasePeer directly, without any generated classes.
+ *
+ * @version $Id: $
+ */
+public class BasePeerTest extends BaseRuntimeTestCase
+{
+    private CountHelper countHelper = new CountHelper();
+
+    /**
+     * Creates a new instance.
+     */
+    public BasePeerTest(String name)
+    {
+        super(name);
+    }
+
+    public void testDeleteGuessTableNameFromCriterion() throws Exception
+    {
+        // prepare
+        cleanBookstore();
+        insertBookstoreData();
+        Criteria criteria = new Criteria();
+        criteria.where(BookPeer.TITLE, "Book 1 - Author 1");
+
+        // execute
+        int deleted = BasePeer.doDelete(criteria);
+
+        // verify
+        assertEquals(1, deleted);
+        assertEquals(99, countHelper.count(BookPeer.getTableMap()));
+        criteria = new Criteria();
+        criteria.where(BookPeer.TITLE, "Book 1 - Author 1");
+        assertEquals(0, countHelper.count(criteria));
+    }
+}

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java Sun Jan 15 14:00:18 2012
@@ -23,6 +23,8 @@ import java.util.List;
 
 import org.apache.torque.BaseRuntimeTestCase;
 import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.Criteria;
+import org.apache.torque.om.mapper.IntegerMapper;
 import org.apache.torque.test.Author;
 import org.apache.torque.test.AuthorPeer;
 import org.apache.torque.test.AuthorRecordMapper;
@@ -77,8 +79,9 @@ public class LargeSelectTest extends Bas
     public void tearDown() throws Exception
     {
         // Delete the test data
-        criteria = new Criteria();
-        criteria.add(AuthorPeer.NAME, LARGE_SELECT_AUTHOR);
+        org.apache.torque.criteria.Criteria criteria
+                = new org.apache.torque.criteria.Criteria();
+        criteria.where(AuthorPeer.NAME, LARGE_SELECT_AUTHOR);
         AuthorPeer.doDelete(criteria);
         criteria = null;
     }
@@ -88,7 +91,11 @@ public class LargeSelectTest extends Bas
      */
     public void testCriteria() throws TorqueException
     {
-        List<Author> result = AuthorPeer.doSelect(criteria);
+        criteria.addSelectColumn(AuthorPeer.AUTHOR_ID);
+        List<Integer> result = BasePeer.doSelect(
+                criteria,
+                new IntegerMapper(),
+                AuthorPeer.getTableMap());
         assertEquals("Selected rows", TEST_ROWS, result.size());
     }
 
@@ -334,7 +341,7 @@ public class LargeSelectTest extends Bas
         criteria.add(AuthorPeer.AUTHOR_ID, firstAuthorId);
 
         LargeSelect<Author> ls = new LargeSelect<Author>(
-                criteria, 
+                criteria,
                 TEST_PAGE_SIZE,
                 "org.apache.torque.test.AuthorPeer",
                 new AuthorRecordMapper());
@@ -436,7 +443,7 @@ public class LargeSelectTest extends Bas
 //    /**
 //     * A basic serialization test.  Cannot continue implementation until
 //     * serialization of Criteria has been implemented correctly.
-//     * 
+//     *
 //     * @throws TorqueException
 //     */
 //    public void testSerialization() throws TorqueException
@@ -450,7 +457,7 @@ public class LargeSelectTest extends Bas
 //
 //        assertEquals("Page size", TEST_PAGE_SIZE, ls.getPageSize());
 //        assertTrue("Paginated", ls.getPaginated());
-//        
+//
 //        List results = ls.getNextResults();
 //        // Page 1
 //        assertEquals("results.size()", TEST_PAGE_SIZE, results.size());
@@ -465,12 +472,12 @@ public class LargeSelectTest extends Bas
 //        assertEquals("Total records", 45, ls.getTotalRecords());
 //        assertEquals("Page progress text", "1 of &gt; 5", ls.getPageProgressText());
 //        assertEquals("Record progress text", "1 - 9 of &gt; 45", ls.getRecordProgressText());
-//        
+//
 //        LargeSelect lsCopy = (LargeSelect) SerializationUtils.clone(ls);
-//        
+//
 //        assertEquals("Page size", TEST_PAGE_SIZE, lsCopy.getPageSize());
 //        assertTrue("Paginated", lsCopy.getPaginated());
-//        
+//
 //        // Page 1
 //        results = lsCopy.getCurrentPageResults();
 //        assertEquals("results.size()", TEST_PAGE_SIZE, results.size());



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


Mime
View raw message