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

svn commit: r1056899 [3/4] - in /db/torque/torque4/trunk: torque-runtime/ torque-runtime/src/main/java/ torque-runtime/src/main/java/org/apache/torque/map/ torque-runtime/src/main/java/org/apache/torque/oid/ torque-runtime/src/main/java/org/apache/torq...

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java?rev=1056899&r1=1056898&r2=1056899&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java Sun Jan  9 09:52:45 2011
@@ -36,10 +36,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
-
-import com.workingdogs.village.DataSetException;
-import com.workingdogs.village.QueryDataSet;
-import com.workingdogs.village.Record;
+import org.apache.torque.om.mapper.RecordMapper;
 
 /**
  * This class can be used to retrieve a large result set from a database query.
@@ -91,23 +88,21 @@ import com.workingdogs.village.Record;
  * </code> allow you to override this for a specific instance of
  * <code>LargeSelect</code> or future instances respectively.
  *
- * <p>Some of the constructors allow you to specify the name of the class to use
- * to build the returnd rows.  This works by using reflection to find <code>
- * addSelectColumns(Criteria)</code> and <code>populateObjects(List)</code>
- * methods to add the necessary select columns to the criteria (only if it
- * doesn't already contain any) and to convert query results from Village
- * <code>Record</code> objects to a class defined within the builder class.
+ * <p>The constructors allow you to specify the name of the class to use
+ * to build the returnd rows.  This works by using reflection to find
+ * the <code>addSelectColumns(Criteria)</code>
+ * method to add the necessary select columns to the criteria (only if it
+ * doesn't already contain any).
  * This allows you to use any of the Torque generated Peer classes, but also
  * makes it fairly simple to construct business object classes that can be used
  * for this purpose (simply copy and customise the <code>addSelectColumns()
- * </code>, <code>populateObjects()</code>, <code>row2Object()</code> and <code>
- * populateObject()</code> methods from an existing Peer class).
+ * </code> method from an existing Peer class).
  *
  * <p>Typically you will create a <code>LargeSelect</code> using your <code>
  * Criteria</code> (perhaps created from the results of a search parameter
- * page), page size, memory page limit and return class name (for which you may
- * have defined a business object class before hand) and place this in user.Temp
- * thus:
+ * page), page size, memory page limit, return class name (for which you may
+ * have defined a business object class before hand) and mapper class 
+ * and place this in user.Temp thus:
  *
  * <pre>
  *     data.getUser().setTemp("someName", largeSelect);
@@ -133,11 +128,13 @@ import com.workingdogs.village.Record;
  * number of convenience methods that make it easy to add all of the necessary
  * bells and whistles to your template.
  *
+ * @param T the type of the objects which are returned on a query.
+ *
  * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
  * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
  * @version $Id$
  */
-public class LargeSelect implements Runnable, Serializable
+public class LargeSelect<T> implements Runnable, Serializable
 {
     /** Serial version */
     private static final long serialVersionUID = -1166842932571491942L;
@@ -154,13 +151,11 @@ public class LargeSelect implements Runn
     /** How much of the memory block is currently occupied with result data. */
     private volatile int currentlyFilledTo = -1;
 
-    /** The SQL query that this <code>LargeSelect</code> represents. */
-    private String query;
     /** The database name to get from Torque. */
     private String dbName;
 
-    /** The memory store of records. */
-    private transient List<Record> results = null;
+    /** The memory store of results. */
+    private transient List<T> results = null;
 
     /** The thread that executes the query. */
     private transient Thread thread = null;
@@ -192,18 +187,18 @@ public class LargeSelect implements Runn
     /** The criteria used for the query. */
     private Criteria criteria = null;
     /** The last page of results that were returned. */
-    private transient List lastResults;
+    private transient List<T> lastResults;
 
     /**
      * The class that is possibly used to construct the criteria and used
      * to transform the Village Records into the desired OM or business objects.
      */
-    private Class returnBuilderClass = null;
+    private Class<?> returnBuilderClass = null;
+
     /**
-     * A reference to the method in the return builder class that will
-     * convert the Village Records to the desired class.
+     * The Mapper used to map the database records into objects.
      */
-    private transient Method populateObjectsMethod = null;
+    private RecordMapper<T> mapper = null;
 
     /**
      * The default value ("&gt;") used to indicate that the total number of
@@ -249,47 +244,6 @@ public class LargeSelect implements Runn
 
     /**
      * Creates a LargeSelect whose results are returned as a <code>List</code>
-     * containing a maximum of <code>pageSize</code> Village <code>Record</code>
-     * objects at a time, maintaining a maximum of
-     * <code>LargeSelect.memoryPageLimit</code> pages of results in memory.
-     *
-     * @param criteria object used by BasePeer to build the query.  In order to
-     * allow this class to utilise database server implemented offsets and
-     * limits (when available), the provided criteria must not have any limit or
-     * offset defined.
-     * @param pageSize number of rows to return in one block.
-     * @throws IllegalArgumentException if <code>criteria</code> uses one or
-     * both of offset and limit, or if <code>pageSize</code> is less than 1;
-     */
-    public LargeSelect(Criteria criteria, int pageSize)
-    {
-        this(criteria, pageSize, LargeSelect.memoryPageLimit);
-    }
-
-    /**
-     * Creates a LargeSelect whose results are returned as a <code>List</code>
-     * containing a maximum of <code>pageSize</code> Village <code>Record</code>
-     * objects at a time, maintaining a maximum of <code>memoryPageLimit</code>
-     * pages of results in memory.
-     *
-     * @param criteria object used by BasePeer to build the query.  In order to
-     * allow this class to utilise database server implemented offsets and
-     * limits (when available), the provided criteria must not have any limit or
-     * offset defined.
-     * @param pageSize number of rows to return in one block.
-     * @param memoryPageLimit maximum number of pages worth of rows to be held
-     * in memory at one time.
-     * @throws IllegalArgumentException if <code>criteria</code> uses one or
-     * both of offset and limit, or if <code>pageSize</code> or
-     * <code>memoryLimitPages</code> are less than 1;
-     */
-    public LargeSelect(Criteria criteria, int pageSize, int memoryPageLimit)
-    {
-        init(criteria, pageSize, memoryPageLimit);
-    }
-
-    /**
-     * Creates a LargeSelect whose results are returned as a <code>List</code>
      * containing a maximum of <code>pageSize</code> objects of the type
      * defined within the class named <code>returnBuilderClassName</code> at a
      * time, maintaining a maximum of <code>LargeSelect.memoryPageLimit</code>
@@ -315,13 +269,15 @@ public class LargeSelect implements Runn
     public LargeSelect(
             Criteria criteria,
             int pageSize,
-            String returnBuilderClassName)
+            String returnBuilderClassName,
+            RecordMapper<T> recordMapper)
     {
         this(
             criteria,
             pageSize,
             LargeSelect.memoryPageLimit,
-            returnBuilderClassName);
+            returnBuilderClassName,
+            recordMapper);
     }
 
     /**
@@ -355,8 +311,10 @@ public class LargeSelect implements Runn
             Criteria criteria,
             int pageSize,
             int memoryPageLimit,
-            String returnBuilderClassName)
+            String returnBuilderClassName,
+            RecordMapper<T> recordMapper)
     {
+        this.mapper = recordMapper;
         try
         {
             this.returnBuilderClass = Class.forName(returnBuilderClassName);
@@ -364,10 +322,10 @@ public class LargeSelect implements Runn
             // Add the select columns if necessary.
             if (criteria.getSelectColumns().size() == 0)
             {
-                Class<?>[] argTypes = { Criteria.class };
+                Class<?>[] argTypes = {Criteria.class};
                 Method selectColumnAdder =
                     returnBuilderClass.getMethod("addSelectColumns", argTypes);
-                Object[] theArgs = { criteria };
+                Object[] theArgs = {criteria};
                 selectColumnAdder.invoke(returnBuilderClass.newInstance(),
                         theArgs);
             }
@@ -383,26 +341,6 @@ public class LargeSelect implements Runn
     }
 
     /**
-     * Access the populateObjects method.
-     *
-     * @throws SecurityException if the security manager does not allow
-     *         access to the method.
-     * @throws NoSuchMethodException if the poulateObjects method does not
-     *         exist.
-     */
-    private Method getPopulateObjectsMethod()
-            throws NoSuchMethodException
-    {
-        if (null == populateObjectsMethod)
-        {
-            Class<?>[] argTypes = { List.class };
-            populateObjectsMethod
-                    = returnBuilderClass.getMethod("populateObjects", argTypes);
-        }
-        return populateObjectsMethod;
-    }
-
-    /**
      * Called by the constructors to start the query.
      *
      * @param criteria Object used by <code>BasePeer</code> to build the query.
@@ -457,7 +395,7 @@ public class LargeSelect implements Runn
      * @throws TorqueException if invoking the <code>populateObjects()<code>
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
-    public List getPage(int pageNumber) throws TorqueException
+    public List<T> getPage(int pageNumber) throws TorqueException
     {
         if (pageNumber < 1)
         {
@@ -475,7 +413,7 @@ public class LargeSelect implements Runn
      * @throws TorqueException if invoking the <code>populateObjects()<code>
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
-    public List getNextResults() throws TorqueException
+    public List<T> getNextResults() throws TorqueException
     {
         if (!getNextResultsAvailable())
         {
@@ -492,7 +430,7 @@ public class LargeSelect implements Runn
      * @throws TorqueException if invoking the <code>populateObjects()<code>
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
-    public List getCurrentPageResults() throws TorqueException
+    public List<T> getCurrentPageResults() throws TorqueException
     {
         return null == lastResults && position > 0
                 ? getResults(position) : lastResults;
@@ -506,7 +444,7 @@ public class LargeSelect implements Runn
      * @throws TorqueException if invoking the <code>populateObjects()<code>
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
-    public List getPreviousResults() throws TorqueException
+    public List<T> getPreviousResults() throws TorqueException
     {
         if (!getPreviousResultsAvailable())
         {
@@ -530,11 +468,11 @@ public class LargeSelect implements Runn
      *
      * @param start the starting row.
      * @return a <code>List</code> of query results containing a maximum of
-     * <code>pageSize</code> reslts.
+     * <code>pageSize</code> results.
      * @throws TorqueException if invoking the <code>populateObjects()<code>
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
-    private List getResults(int start) throws TorqueException
+    private List<T> getResults(int start) throws TorqueException
     {
         return getResults(start, pageSize);
     }
@@ -546,14 +484,14 @@ public class LargeSelect implements Runn
      * @param start the starting row.
      * @param size the number of rows.
      * @return a <code>List</code> of query results containing a maximum of
-     * <code>pageSize</code> reslts.
+     * <code>pageSize</code> results.
      * @throws IllegalArgumentException if <code>size &gt; memoryLimit</code> or
      * <code>start</code> and <code>size</code> result in a situation that is
      * not catered for.
      * @throws TorqueException if invoking the <code>populateObjects()<code>
      * method runs into problems or a sleep is unexpectedly interrupted.
      */
-    private synchronized List getResults(int start, int size)
+    private synchronized List<T> getResults(int start, int size)
             throws TorqueException
     {
         if (log.isDebugEnabled())
@@ -655,27 +593,14 @@ public class LargeSelect implements Runn
                     + toIndex + ")");
         }
 
-        List returnResults;
+        List<T> returnResults;
 
         synchronized (results)
         {
-            returnResults = new ArrayList(results.subList(fromIndex, toIndex));
+            returnResults = new ArrayList<T>(
+                    results.subList(fromIndex, toIndex));
         }
 
-        if (null != returnBuilderClass)
-        {
-            // Invoke the populateObjects() method
-            Object[] theArgs = { returnResults };
-            try
-            {
-                returnResults = (List) getPopulateObjectsMethod().invoke(
-                        returnBuilderClass.newInstance(), theArgs);
-            }
-            catch (Exception e)
-            {
-                throw new TorqueException("Unable to populate results", e);
-            }
-        }
         position = start + size;
         lastResults = returnResults;
         return returnResults;
@@ -686,62 +611,18 @@ public class LargeSelect implements Runn
      */
     public void run()
     {
-        boolean dbSupportsNativeLimit;
-        boolean dbSupportsNativeOffset;
-        try
-        {
-            dbSupportsNativeLimit
-                    = (Torque.getDB(dbName).supportsNativeLimit());
-            dbSupportsNativeOffset
-                    = (Torque.getDB(dbName).supportsNativeOffset());
-        }
-        catch (TorqueException e)
-        {
-            log.error("run() : Exiting :", e);
-            // we cannot execute further because Torque is not initialized
-            // correctly
-            return;
-        }
-
-        int size;
-        if (dbSupportsNativeLimit && dbSupportsNativeOffset)
-        {
-            // retrieve one page at a time
-            size = pageSize;
-        }
-        else
-        {
-            // retrieve the whole block at once and add the offset,
-            // and add one record to check if we have reached the end of the
-            // data
-            size = blockBegin + memoryLimit + 1;
-        }
         /* The connection to the database. */
         Connection conn = null;
-        /** Used to retrieve query results from Village. */
-        QueryDataSet qds = null;
 
         try
         {
             // Add 1 to memory limit to check if the query ends on a page break.
-            results = new ArrayList<Record>(memoryLimit + 1);
+            results = new ArrayList<T>(memoryLimit + 1);
 
-            // Use the criteria to limit the rows that are retrieved to the
-            // block of records that fit in the predefined memoryLimit.
-            if (dbSupportsNativeLimit)
-            {
-                if (dbSupportsNativeOffset)
-                {
-                    criteria.setOffset(blockBegin);
-                    // Add 1 to memory limit to check if the query ends on a
-                    // page break.
-                    criteria.setLimit(memoryLimit + 1);
-                }
-                else
-                {
-                    criteria.setLimit(blockBegin + memoryLimit + 1);
-                }
-            }
+            criteria.setOffset(blockBegin);
+            // Add 1 to memory limit to check if the query ends on a
+            // page break.
+            criteria.setLimit(memoryLimit + 1);
 
             /*
              * Fix criterions relating to booleanint or booleanchar columns
@@ -751,7 +632,7 @@ public class LargeSelect implements Runn
              */
             BasePeer.correctBooleans(criteria, null);
 
-            query = BasePeer.createQueryString(criteria);
+            String query = BasePeer.createQueryString(criteria);
 
             // Get a connection to the db.
             conn = Torque.getConnection(dbName);
@@ -764,62 +645,39 @@ public class LargeSelect implements Runn
                 log.debug("run(): blockBegin = " + blockBegin);
                 log.debug("run(): blockEnd = " + blockEnd);
             }
-            qds = new QueryDataSet(conn, query);
 
             // Continue getting rows one page at a time until the memory limit
             // is reached, all results have been retrieved, or the rest
             // of the results have been determined to be irrelevant.
+            boolean allRecordsRetrieved = false;
             while (!killThread
-                && !qds.allRecordsRetrieved()
+                && !allRecordsRetrieved
                 && currentlyFilledTo + pageSize <= blockEnd)
             {
-                // This caters for when memoryLimit is not a multiple of
-                //  pageSize which it never is because we always add 1 above.
-                // not applicable if the db has no native limit where this
-                // was already considered
-                if ((currentlyFilledTo + pageSize) >= blockEnd
-                        && dbSupportsNativeLimit)
+                if (log.isDebugEnabled())
                 {
-                    // Add 1 to check if the query ends on a page break.
-                    size = blockEnd - currentlyFilledTo + 1;
+                    log.debug("run(): Invoking BasePeer.doSelect()");
                 }
 
-                if (log.isDebugEnabled())
+                List<T> tempResults
+                        = BasePeer.doSelect(criteria, mapper, null, conn);
+                if (tempResults.size() < criteria.getLimit())
                 {
-                    log.debug("run(): Invoking BasePeer.getSelectResults(qds, "
-                            + size + ", false)");
+                    allRecordsRetrieved = true;
                 }
 
-                List<Record> tempResults
-                        = BasePeer.getSelectResults(qds, size, false);
-
-                int startIndex = dbSupportsNativeOffset ? 0 : blockBegin;
-
                 synchronized (results)
                 {
-                    for (int i = startIndex, n = tempResults.size(); i < n; i++)
-                    {
-                        results.add(tempResults.get(i));
-                    }
+                    results.addAll(tempResults);
                 }
 
-                if (dbSupportsNativeLimit && dbSupportsNativeOffset)
-                {
-                    currentlyFilledTo += tempResults.size();
-                }
-                else
-                {
-                    currentlyFilledTo = tempResults.size() - 1 - blockBegin;
-                }
+                currentlyFilledTo += tempResults.size();
 
                 boolean perhapsLastPage = true;
 
                 // If the extra record was indeed found then we know we are not
                 // on the last page but we must now get rid of it.
-                if ((dbSupportsNativeLimit
-                        && (results.size() == memoryLimit + 1))
-                    || (!dbSupportsNativeLimit
-                            && currentlyFilledTo >= memoryLimit))
+                if (results.size() == memoryLimit + 1)
                 {
                     synchronized (results)
                     {
@@ -836,10 +694,8 @@ public class LargeSelect implements Runn
                 }
 
                 // if the db has limited the datasets, we must retrieve all
-                // datasets. If not, we are always finished because we fetch
-                // the whole block at once.
-                if (qds.allRecordsRetrieved()
-                        || !dbSupportsNativeLimit)
+                // datasets.
+                if (allRecordsRetrieved)
                 {
                     queryCompleted = true;
                     // The following ugly condition ensures that the totals are
@@ -851,14 +707,13 @@ public class LargeSelect implements Runn
                         totalsFinalized = true;
                     }
                 }
-                qds.clearRecords();
             }
 
             if (log.isDebugEnabled())
             {
                 log.debug("run(): While loop terminated because either:");
                 log.debug("run(): 1. qds.allRecordsRetrieved(): "
-                        + qds.allRecordsRetrieved());
+                        + allRecordsRetrieved);
                 log.debug("run(): 2. killThread: " + killThread);
                 log.debug("run(): 3. !(currentlyFilledTo + size <= blockEnd): !"
                         + (currentlyFilledTo + pageSize <= blockEnd));
@@ -872,32 +727,9 @@ public class LargeSelect implements Runn
         {
             log.error(e);
         }
-        catch (SQLException e)
-        {
-            log.error(e);
-        }
-        catch (DataSetException e)
-        {
-            log.error(e);
-        }
         finally
         {
-            try
-            {
-                if (qds != null)
-                {
-                    qds.close();
-                }
-                Torque.closeConnection(conn);
-            }
-            catch (SQLException e)
-            {
-                log.error(e);
-            }
-            catch (DataSetException e)
-            {
-                log.error(e);
-            }
+            Torque.closeConnection(conn);
             threadRunning = false;
         }
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Query.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Query.java?rev=1056899&r1=1056898&r2=1056899&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Query.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Query.java Sun Jan  9 09:52:45 2011
@@ -35,11 +35,17 @@ import org.apache.commons.lang.StringUti
  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
  * @author <a href="mailto:fischer@seitenbau.de">Thomas Fischer</a>
  * @version $Id$
+ *
+ * TODO rename to SqlStatement
  */
 public class Query
 {
+    public enum Type { SELECT, UPDATE, DELETE };
     private static final String SELECT = "SELECT ";
+    private static final String UPDATE = "UPDATE ";
+    private static final String DELETE_FROM = "DELETE FROM ";
     private static final String FROM = " FROM ";
+    private static final String SET = " SET ";
     private static final String WHERE = " WHERE ";
     private static final String AND = " AND ";
     private static final String ORDER_BY = " ORDER BY ";
@@ -49,8 +55,11 @@ public class Query
     private static final String OFFSET = " OFFSET ";
     private static final String ROWCOUNT = " SET ROWCOUNT ";
 
+    // TODO rename to columns
+    private UniqueList<String> updateColumns = new UniqueList<String>();
     private UniqueList<String> selectModifiers = new UniqueList<String>();
     private UniqueList<String> selectColumns = new UniqueList<String>();
+    // TODO rename to tables
     private UniqueList<FromElement> fromTables = new UniqueList<FromElement>();
     private UniqueList<String> whereCriteria = new UniqueList<String>();
     private UniqueList<String> orderByColumns = new UniqueList<String>();
@@ -61,6 +70,7 @@ public class Query
     private String postLimit;
     private String offset;
     private String rowcount;
+    private Type type = Type.SELECT;
 
     /**
      * Retrieve the modifier buffer in order to add modifiers to this
@@ -87,7 +97,6 @@ public class Query
      * Retrieve the columns buffer in order to specify which columns
      * are returned in this query.
      *
-     *
      * @return An UniqueList used to add columns to be selected.
      */
     public UniqueList<String> getSelectClause()
@@ -96,9 +105,9 @@ public class Query
     }
 
     /**
-     * Set the columns.
+     * Set the columns which are returned by this query.
      *
-     * @param columns columns list
+     * @param columns the columns list, not null.
      */
     public void setSelectClause(UniqueList<String> columns)
     {
@@ -106,6 +115,16 @@ public class Query
     }
 
     /**
+     * Returns the columns which are updated by this query.
+     *
+     * @return An UniqueList which can used to add columns to be updated.
+     */
+    public UniqueList<String> getUpdateColumns()
+    {
+        return updateColumns;
+    }
+
+    /**
      * Retrieve the from buffer in order to specify which tables are
      * involved in this query.
      *
@@ -315,6 +334,32 @@ public class Query
     }
 
     /**
+     * Sets the type of this SQL statement.
+     *
+     * @param type the new type, not null.
+     *
+     * @throws NullPointerException if <code>type</code> is null.
+     */
+    public void setType(Type type)
+    {
+        if (type == null)
+        {
+            throw new NullPointerException("type is null");
+        }
+        this.type = type;
+    }
+
+    /**
+     * Returns the type of this SQL statement.
+     *
+     * @return type the new type, not null.
+     */
+    public Type getType()
+    {
+        return type;
+    }
+
+    /**
      * Outputs the query statement.
      *
      * @return A String with the query statement.
@@ -337,10 +382,22 @@ public class Query
                 .append(rowcount)
                 .append(" ");
         }
-        stmt.append(SELECT)
-            .append(StringUtils.join(selectModifiers.iterator(), " "))
-            .append(StringUtils.join(selectColumns.iterator(), ", "))
-            .append(FROM);
+
+        if (Type.SELECT == type)
+        {
+            stmt.append(SELECT)
+                .append(StringUtils.join(selectModifiers.iterator(), " "))
+                .append(StringUtils.join(selectColumns.iterator(), ", "))
+                .append(FROM);
+        }
+        else if (Type.UPDATE == type)
+        {
+            stmt.append(UPDATE);
+        }
+        else if (Type.DELETE == type)
+        {
+            stmt.append(DELETE_FROM);
+        }
 
         boolean first = true;
         for (Iterator<FromElement> it = fromTables.iterator(); it.hasNext();)
@@ -355,6 +412,16 @@ public class Query
             stmt.append(fromElement.toString());
         }
 
+        if (Type.UPDATE == type)
+        {
+            stmt.append(SET)
+                .append(StringUtils.join(selectColumns, "=?, "));
+            if (!selectColumns.isEmpty())
+            {
+                stmt.append("=?");
+            }
+        }
+
         if (!whereCriteria.isEmpty())
         {
             stmt.append(WHERE)

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java?rev=1056899&r1=1056898&r2=1056899&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java Sun Jan  9 09:52:45 2011
@@ -22,6 +22,10 @@ package org.apache.torque.util;
 import java.io.IOException;
 import java.io.Writer;
 import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
@@ -30,12 +34,10 @@ import org.apache.commons.collections.Or
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.TorqueException;
+import org.apache.torque.om.mapper.ObjectListMapper;
+import org.apache.torque.om.mapper.RecordMapper;
 import org.apache.torque.util.functions.SQLFunction;
 
-import com.workingdogs.village.DataSetException;
-import com.workingdogs.village.Record;
-import com.workingdogs.village.Value;
-
 /**
  * <p>A utility to help produce aggregate summary information about a table.
  * The default assumes that the underlying DB supports the SQL 99 Standard
@@ -61,11 +63,10 @@ import com.workingdogs.village.Value;
  *    sHelper.addAggregate(FunctionFactory.Max(TimeSheetPeer.HOURS),"Max_Hrs");
  *    List results = sHelper.summarize( c );
  * </pre>
- * <p>The results list will be an ListOrderedMapCI with a key of either the
- * group by column name or the name specified for the aggregate function (e.g.
- * EMPLOYEE or Hours).  The value will be a Village Value Class.  Below is
- * a simple way to do this.  See the dumpResults* method code for a more
- * complex example.
+ * <p>The results list will be an OrderedMap with a key of either the group by
+ * column name or the name specified for the aggregate function (e.g. EMPLOYEE
+ * or Hours).  The value will be a Village Value Class.  Below is a simple
+ * way to do this.  See the dumpResults* method code for a more complex example.
  * </p>
  * <pre>
  *    String emp = results.get("EMPLOYEE").asString();
@@ -83,18 +84,17 @@ import com.workingdogs.village.Value;
  *
  * @see org.apache.torque.util.functions.FunctionFactory
  * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
- * @version $Id$
+ * @version $Id: $
  */
 public class SummaryHelper
 {
-    static Log logger = LogFactory.getLog(SummaryHelper.class);
+    /** The class log. */
+    private static Log logger = LogFactory.getLog(SummaryHelper.class);
 
     /** A list of the group by columns names (e.g. TABLE.COLUMN) */
-    private List groupByColumns;
-    /**
-     * A ListOrderMapCI<String,Aggregate.Function> with the aggregate
-     * functions to use in generating results.
-     */
+    private List<String> groupByColumns;
+    /** A ListOrderMapCI<String, Aggregate.Function> with the aggregate functions
+     * to use in generating results. */
     private ListOrderedMapCI aggregates;
     /** Flag for excluding unnamed columns. */
     private boolean excludeExprColumns = false;
@@ -111,61 +111,188 @@ public class SummaryHelper
      * Return a list of ListOrderedMapCI objects with the results of the summary
      * query.  The ListOrderedMapCI objects have a key of the column name or
      * function alias and are in the order generated by the query.
+     * The class of the return values are decided by the database driver,
+     * which makes this method not database independent.
      *
      * @param crit The base criteria to build on.
-     * @return Results as a ListOrderMapCI<String,Values> object.
-     * @throws TorqueException
-     * @throws DataSetException
+     *
+     * @return Results as a OrderMap<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
      */
-    public List summarize( Criteria crit )
-                                throws TorqueException, DataSetException
+    public List<ListOrderedMapCI> summarize(Criteria crit)
+            throws TorqueException
     {
-        return summarize( crit, null );
+        return summarize(crit, (List<Class<?>>) null);
+    }
+
+     /**
+     * Return a list of ListOrderedMapCI objects with the results of the summary
+     * query.  The ListOrderedMapCI objects have a key of the column name or
+     * function alias and are in the order generated by the query.
+     *
+     * @param crit The base criteria to build on.
+     * @param resultTypes the classes to which the return values of the query
+     *        should be cast, or null to let the database driver decide.
+     *        See org.apache.torque.om.mapper.ObjectListMapper´for the supported
+     *        classes.
+     *
+     * @return Results as a ListOrderMapCI<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<ListOrderedMapCI> summarize(
+                Criteria crit,
+                List<Class<?>> resultTypes)
+            throws TorqueException
+    {
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    crit.getDbName(),
+                    crit.isUseTransaction());
+            List<ListOrderedMapCI> result = summarize(crit, resultTypes, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
     }
 
     /**
-     * Return a list of ListOrderedMapCI objects with the results of the
-     * summary query.  The ListOrderedMapCI objects have a key of the column
-     * name or function alias and are in the order generated by the query.
+     * Return a list of OrderedMap objects with the results of the summary
+     * query.  The OrderedMap objects have a key of the column name or
+     * function alias and are in the order generated by the query.
+     * The class of the return values are decided by the database driver,
+     * which makes this method not database independent.
      *
      * @param crit The base criteria to build on.
      * @param conn The DB Connection to use.
-     * @return Results as a ListOrderMapCI<String,Values> object.
-     * @throws TorqueException
-     * @throws DataSetException
-     * @see ListOrderedMapCI
+     *
+     * @return Results as a OrderMap<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
      */
-    public List summarize( Criteria crit, Connection conn )
-                                 throws TorqueException, DataSetException
+    public List<ListOrderedMapCI> summarize(Criteria crit, Connection conn)
+            throws TorqueException
     {
-        Criteria c = buildCriteria( crit );
+        return summarize(crit, null, conn);
+    }
 
-        List results;
-        if (conn == null)
+    /**
+     * Return a list of ListOrderedMapCI objects with the results of the summary
+     * query.  The ListOrderedMapCI objects have a key of the column name or
+     * function alias and are in the order generated by the query.
+     *
+     * @param crit The base criteria to build on.
+     * @param resultTypes the classes to which the return values of the query
+     *        should be cast, or null to let the database driver decide.
+     *        See org.apache.torque.om.mapper.ObjectListMapper´for the supported
+     *        classes.
+     * @param conn The DB Connection to use.
+     *
+     * @return Results as a ListOrderedMapCI<String,Values> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<ListOrderedMapCI> summarize(
+                Criteria crit,
+                List<Class<?>> resultTypes,
+                Connection conn)
+            throws TorqueException
+    {
+        Criteria c = buildCriteria(crit);
+        String query = BasePeer.createQuery(c).toString();
+        RecordMapper<List<Object>> mapper = new ObjectListMapper(resultTypes);
+
+        Statement statement = null;
+        ResultSet resultSet = null;
+        List<List<Object>> rows = new ArrayList<List<Object>>();
+        try
+        {
+            statement = conn.createStatement();
+            long startTime = System.currentTimeMillis();
+            logger.debug("Executing query " + query);
+
+            resultSet = statement.executeQuery(query.toString());
+            long queryEndTime = System.currentTimeMillis();
+            logger.trace("query took " + (queryEndTime - startTime)
+                    + " milliseconds");
+
+            while (resultSet.next())
+            {
+                List<Object> rowResult = mapper.processRow(resultSet, 0);
+                rows.add(rowResult);
+            }
+            long mappingEndTime = System.currentTimeMillis();
+            logger.trace("mapping took " + (mappingEndTime - queryEndTime)
+                    + " milliseconds");
+        }
+        catch (SQLException e)
         {
-            results = BasePeer.doSelectVillageRecords(c);
+            throw new TorqueException(e);
         }
-        else
+        finally
         {
-            results = BasePeer.doSelectVillageRecords(c, conn);
+            if (resultSet != null)
+            {
+                try
+                {
+                    resultSet.close();
+                }
+                catch (SQLException e)
+                {
+                    logger.warn("error closing resultSet", e);
+                }
+            }
+            if (statement != null)
+            {
+                try
+                {
+                    statement.close();
+                }
+                catch (SQLException e)
+                {
+                    logger.warn("error closing statement", e);
+                }
+            }
         }
 
-        Iterator r = results.iterator();
-
-        Vector resultsList = new Vector(results.size());
-        while ( r.hasNext() )
+        List<ListOrderedMapCI> resultsList = new Vector<ListOrderedMapCI>(rows.size());
+        List<String> columnNames = new ArrayList<String>();
+        for (String columnName : c.getSelectColumns())
+        {
+            int dotPos = columnName.lastIndexOf(".");
+            String unqualifiedColumnName;
+            if (dotPos == -1)
+            {
+                unqualifiedColumnName = columnName;
+            }
+            else
+            {
+                unqualifiedColumnName = columnName.substring(dotPos + 1);
+            }
+            columnNames.add(unqualifiedColumnName);
+        }
+        columnNames.addAll(c.getAsColumns().keySet());
+        for (List<Object> row : rows)
         {
             ListOrderedMapCI recordMap = new ListOrderedMapCI();
-            Record rec = (Record) r.next();
-            String cName = null;
-            Value value = null;
-            for ( int i = 1; i <= rec.size(); i++ )
+            for (int i = 0; i < row.size(); i++)
             {
-                value = rec.getValue(i);
-                cName = rec.schema().column(i).name();
-                if ( cName == null || cName.equals("") )
+                Object value = row.get(i);
+                String cName = columnNames.get(i);
+                if (cName == null || cName.equals(""))
                  {
-                    if ( excludeExprColumns() ) {
+                    if (excludeExprColumns())
+                    {
                         continue;
                     }
                     cName = "Expr" + i;
@@ -185,12 +312,12 @@ public class SummaryHelper
      * @return A criteria to use in summarizing the information.
      * @throws TorqueException
      */
-    public Criteria buildCriteria( Criteria c ) throws TorqueException {
-
+    public Criteria buildCriteria(Criteria c) throws TorqueException
+    {
         c.getSelectColumns().clear();
         c.getGroupByColumns().clear();
 
-        UniqueList criteriaSelectModifiers;
+        UniqueList<String> criteriaSelectModifiers;
         criteriaSelectModifiers = c.getSelectModifiers();
 
         if (criteriaSelectModifiers != null
@@ -201,23 +328,22 @@ public class SummaryHelper
         }
         c.setIgnoreCase(false);
 
-        List cols = null;
-        Iterator i = null;
+        List<String> cols = null;
 
         cols = getGroupByColumns();
-        i = cols.iterator();
-        boolean haveFromTable = i.hasNext(); // Group By cols define src table.
-        while ( i.hasNext() )
+        boolean haveFromTable = !cols.isEmpty(); // Group By cols define src table.
+        for (String col : cols)
         {
-            String col = (String) i.next();
-            c.addGroupByColumn( col );
+            c.addGroupByColumn(col);
             c.addSelectColumn(col);
         }
-        if ( haveFromTable )
+        if (haveFromTable)
+        {
             logger.debug("From table defined by Group By Cols");
+        }
 
         // Check if the from table is set via a where clause.
-        if ( ! haveFromTable && c.keys().hasMoreElements() )
+        if (!haveFromTable && c.keys().hasMoreElements())
         {
             haveFromTable = true;
             logger.debug("From table defined by a where clause");
@@ -225,32 +351,32 @@ public class SummaryHelper
 
         ListOrderedMapCI cMap = getAggregates();
         OrderedMapIterator iMap = cMap.orderedMapIterator();
-        while ( iMap.hasNext() )
+        while (iMap.hasNext())
         {
             String key = (String) iMap.next();
             SQLFunction f = (SQLFunction) iMap.getValue();
-            c.addAsColumn( key, f.toSQL() );
-            if ( ! haveFromTable )    // Last chance. Get it from the func.
+            c.addAsColumn(key, f.toSQL());
+            if (!haveFromTable)    // Last chance. Get it from the func.
             {
                 String col =  f.getArgument(0).toString();
-                if ( col.contains(".") )
+                if (col.contains("."))
                 {
                     // Kludgy Where table.col = table.col clause to force
                     // from table identification.
-                    c.add( col,(Object)(col + "=" + col), SqlEnum.CUSTOM );
+                    c.add(col, (Object) (col + "=" + col), SqlEnum.CUSTOM);
                     haveFromTable = true;
 
-                    String table = col.substring(0,col.indexOf('.'));
-                    logger.debug("From table, '" + table +
-                                 "', defined from aggregate column");
+                    String table = col.substring(0, col.indexOf('.'));
+                    logger.debug("From table, '" + table
+                            + "', defined from aggregate column");
                 }
             }
         }
-        if ( ! haveFromTable )
+        if (!haveFromTable)
         {
             throw new TorqueException(
-                         "No FROM table defined by the GroupBy set, " +
-                         "criteria.setAlias, or specified function column!");
+                    "No FROM table defined by the GroupBy set, "
+                    + "criteria.setAlias, or specified function column!");
         }
         return c;
     }
@@ -269,7 +395,7 @@ public class SummaryHelper
      *
      * @param column
      */
-    public void addGroupBy( String column )
+    public void addGroupBy(String column)
     {
         getGroupByColumns().add(column);
     }
@@ -281,9 +407,9 @@ public class SummaryHelper
      *               no key words, e.g. function names.
      * @param function One of the inner classes from the Aggregate class.
      */
-    public void addAggregate( String alias, SQLFunction function )
+    public void addAggregate(String alias, SQLFunction function)
     {
-        getAggregates().put( alias, function );
+        getAggregates().put(alias, function);
     }
 
     /**
@@ -297,11 +423,11 @@ public class SummaryHelper
         setExcludeExprColumns(false);
     }
 
-    public List getGroupByColumns()
+    public List<String> getGroupByColumns()
     {
-        if ( groupByColumns == null )
+        if (groupByColumns == null)
         {
-            groupByColumns = new Vector();
+            groupByColumns = new Vector<String>();
         }
         return groupByColumns;
     }
@@ -315,7 +441,7 @@ public class SummaryHelper
      */
     public ListOrderedMapCI getAggregates()
     {
-        if ( aggregates == null )
+        if (aggregates == null)
         {
             aggregates = new ListOrderedMapCI();
         }
@@ -332,44 +458,37 @@ public class SummaryHelper
      * @param includeHeader
      * @throws IOException
      */
-    public void dumpResults(Writer out, List results, boolean includeHeader )
+    public void dumpResults(Writer out, List<?> results, boolean includeHeader)
                                                             throws IOException
     {
-        Iterator i = results.iterator();
+        Iterator<?> i = results.iterator();
         boolean first = includeHeader;
 
-        while ( i.hasNext() )
+        while (i.hasNext())
         {
             ListOrderedMapCI rec = (ListOrderedMapCI) i.next();
             OrderedMapIterator rI = rec.orderedMapIterator();
             String heading = "";
             String recString = "";
-            while ( rI.hasNext() )
+            while (rI.hasNext())
             {
                 String colId = (String) rI.next();
-                if ( first )
+                if (first)
                 {
                     heading += "\"" + colId + "\"";
-                    if ( rI.hasNext() )
+                    if (rI.hasNext())
                     {
                         heading += ", ";
                     }
                 }
-                Value v = (Value) rI.getValue();
-                if ( v.isString() )
-                {
-                    recString += "\"" + v.toString() + "\"";
-                } 
-                else 
-                {
-                    recString += v.toString();
-                }
-                if ( rI.hasNext() )
+                Object v = rI.getValue();
+                recString += v.toString();
+                if (rI.hasNext())
                 {
                     recString += ", ";
                 }
             }
-            if ( first )
+            if (first)
             {
                 first = false;
                 out.write(heading);
@@ -404,4 +523,5 @@ public class SummaryHelper
     {
         this.excludeExprColumns = excludeExprColumns;
     }
+
 }

Propchange: db/torque/torque4/trunk/torque-runtime/src/test/java/org/
            ('svn:mergeinfo' removed)

Modified: db/torque/torque4/trunk/torque-site/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/changes/changes.xml?rev=1056899&r1=1056898&r2=1056899&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-site/src/changes/changes.xml (original)
+++ db/torque/torque4/trunk/torque-site/src/changes/changes.xml Sun Jan  9 09:52:45 2011
@@ -24,6 +24,9 @@
 
   <body>
   <release version="4.0-alpha1-SNAPSHOT" date="in SVN">
+    <action type="remove" dev="tfischer">
+      Do not use Village anymore and remove it from the dependencies.
+    </action>
     <action type="update" dev="gmonroe">
       Fixed SummaryHelper class issues caused by DB differences.
       Added a ListOrderMapCI class to utils (case insensitive string keys).

Propchange: db/torque/torque4/trunk/torque-site/src/changes/changes.xml
            ('svn:mergeinfo' removed)

Propchange: db/torque/torque4/trunk/torque-site/src/site/resources/images/
            ('svn:mergeinfo' removed)

Propchange: db/torque/torque4/trunk/torque-site/src/site/xdoc/
            ('svn:mergeinfo' removed)

Propchange: db/torque/torque4/trunk/torque-test/src/
            ('svn:mergeinfo' removed)

Propchange: db/torque/torque4/trunk/torque-test/src/main/schema/
            ('svn:mergeinfo' removed)

Propchange: db/torque/torque4/trunk/torque-test/src/test/java/
            ('svn:mergeinfo' removed)

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=1056899&r1=1056898&r2=1056899&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  9 09:52:45 2011
@@ -25,12 +25,10 @@ import junit.framework.TestCase;
 
 import org.apache.torque.adapter.DB;
 import org.apache.torque.adapter.DBMM;
+import org.apache.torque.map.TableMap;
+import org.apache.torque.om.mapper.StringMapper;
 import org.apache.torque.util.BasePeer;
 
-import com.workingdogs.village.DataSetException;
-import com.workingdogs.village.Record;
-import com.workingdogs.village.Value;
-
 /**
  * Base functionality to be extended by all Torque test cases.  Test
  * case implementations are used to automate unit testing via JUnit.
@@ -73,10 +71,8 @@ public abstract class BaseRuntimeTestCas
      * Queries mysql for its version.
      * @return the version String mysql returns
      * @throws TorqueException if the database is not mysql or the query fails.
-     * @throws DataSetException if the version string can not be extracted from
-     *         the select result.
      */
-    protected String getMysqlVersion() throws TorqueException, DataSetException
+    protected String getMysqlVersion() throws TorqueException
     {
         DB adapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
         if (!(adapter instanceof DBMM))
@@ -85,24 +81,23 @@ public abstract class BaseRuntimeTestCas
                     "getMysqlVersion called but database adapter is "
                         + adapter.getClass().getName());
         }
-        List records = BasePeer.executeQuery("show variables like \"version\"");
-        Record record = (Record) records.get(0);
-        Value versionValue = record.getValue("Value");
-        String version = versionValue.asString();
-        return version;
+        List<String> records = BasePeer.doSelect(
+                "show variables like \"version\"",
+                new StringMapper(1),
+                (TableMap) null,
+                (String) null);
+        return records.get(0);
     }
 
     /**
      * Queries mysql for its major version. (format is major.minor.release)
      * @return the major version of mysql
      * @throws TorqueException if the database is not mysql or the query fails.
-     * @throws DataSetException if the version string can not be extracted from
-     *         the select result.
      * @throws NumberFormatException if the mysql major version cannot be 
      *         converted to an int 
      */
     protected int getMysqlMajorVersion()
-        throws TorqueException, DataSetException
+        throws TorqueException
     {
         String completeVersion = getMysqlVersion();
         String majorVersion
@@ -114,11 +109,9 @@ public abstract class BaseRuntimeTestCas
      * Queries mysql for its minor version. (format is major.minor.release)
      * @return the minor version of mysql
      * @throws TorqueException if the database is not mysql or the query fails.
-     * @throws DataSetException if the version string can not be extracted from
-     *         the select result.
      */
     protected int getMysqlMinorVersion()
-        throws TorqueException, DataSetException
+        throws TorqueException
     {
         String completeVersion = getMysqlVersion();
         String minorVersion

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=1056899&r1=1056898&r2=1056899&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  9 09:52:45 2011
@@ -20,14 +20,17 @@ package org.apache.torque;
  */
 
 import java.sql.Connection;
+import java.sql.ResultSet;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -46,6 +49,9 @@ import org.apache.torque.adapter.DBOracl
 import org.apache.torque.adapter.DBSybase;
 import org.apache.torque.adapter.DBWeblogic;
 import org.apache.torque.om.StringKey;
+import org.apache.torque.om.mapper.CompositeMapper;
+import org.apache.torque.om.mapper.IntegerMapper;
+import org.apache.torque.om.mapper.RecordMapper;
 import org.apache.torque.test.A;
 import org.apache.torque.test.APeer;
 import org.apache.torque.test.Author;
@@ -97,8 +103,6 @@ import org.apache.torque.util.CountHelpe
 import org.apache.torque.util.Criteria;
 import org.apache.torque.util.Transaction;
 
-import com.workingdogs.village.Record;
-
 /**
  * Runtime tests.
  *
@@ -205,21 +209,23 @@ public class DataTest extends BaseRuntim
     }
 
     private static final String[] validTitles = {
-        "Book 7 - Author 8", "Book 6 - Author 8", "Book 7 - Author 7",
-        "Book 6 - Author 7", "Book 7 - Author 6", "Book 6 - Author 6",
-        "Book 7 - Author 5", "Book 6 - Author 5", "Book 7 - Author 4",
-        "Book 6 - Author 4"};
+        "Book 6 - Author 4", "Book 6 - Author 5", "Book 6 - Author 6",
+        "Book 6 - Author 7", "Book 6 - Author 8", 
+        "Book 7 - Author 4", "Book 7 - Author 5", "Book 7 - Author 6",
+        "Book 7 - Author 7", "Book 7 - Author 8"
+        };
 
     /**
-     * test limit/offset which was broken for oracle (TRQ47)
+     * test limit/offset
+     *
      * @throws Exception if the test fails
      */
     public void testLimitOffset() throws Exception
     {
-        Map titleMap = new HashMap();
+        Set<String> titleSet = new HashSet<String>();
         for (int j = 0; j < validTitles.length; j++)
         {
-            titleMap.put(validTitles[j], null);
+            titleSet.add(validTitles[j]);
         }
 
         Criteria crit = new Criteria();
@@ -231,15 +237,17 @@ public class DataTest extends BaseRuntim
         crit.addDescendingOrderByColumn(BookPeer.BOOK_ID);
         crit.setLimit(10);
         crit.setOffset(5);
-        List books = BookPeer.doSelect(crit);
+        List<Book> books = BookPeer.doSelect(crit);
         assertTrue("List should have 10 books, not " + books.size(),
                 books.size() == 10);
-        for (Iterator i = books.iterator(); i.hasNext();)
+        for (Book book : books)
         {
-            String title = ((Book) i.next()).getTitle();
+            String title = book.getTitle();
             assertTrue("Incorrect title: " + title,
-                    titleMap.containsKey(title));
+                    titleSet.contains(title));
         }
+
+        // Test limit of zero works
         crit.clear();
         crit.setLimit(0);
         try
@@ -265,7 +273,7 @@ public class DataTest extends BaseRuntim
         books = MyBookPeer.doSelect(crit);
         assertTrue("List should have 95 books, not " + books.size(),
                 books.size() == 95);
-        
+
         // Check that limiting also works if a table with an equal column name
         // is joined. This is problematic for oracle, see TORQUE-10.
         
@@ -431,7 +439,7 @@ public class DataTest extends BaseRuntim
         BitCompositePkPeer.doDelete(criteria);
 
         BitCompositePk bitCompositePk = new BitCompositePk();
-        bitCompositePk.setPk1("value");
+        bitCompositePk.setPk1("false value");
         bitCompositePk.setPk2(Boolean.FALSE);
         bitCompositePk.setPayload("false payload");
         bitCompositePk.save();
@@ -439,18 +447,18 @@ public class DataTest extends BaseRuntim
         bitCompositePk = new BitCompositePk();
         bitCompositePk.setPk1("true value");
         bitCompositePk.setPk2(Boolean.TRUE);
-        bitCompositePk.setPayload("double true payload");
+        bitCompositePk.setPayload("true payload");
         bitCompositePk.save();
 
         bitCompositePk = new BitCompositePk();
         bitCompositePk.setPk1("value");
         bitCompositePk.setPk2(Boolean.TRUE);
-        bitCompositePk.setPayload("true payload");
+        bitCompositePk.setPayload("payload");
         bitCompositePk.save();
 
         // check we get correct result when pks match
         criteria = new Criteria();
-        criteria.and(BitCompositePkPeer.PK1, "value");
+        criteria.and(BitCompositePkPeer.PK1, "false value");
         criteria.and(BitCompositePkPeer.PK2, Boolean.FALSE);
         List<BitCompositePk> result 
             = BitCompositePkPeer.doSelect(criteria);
@@ -462,18 +470,18 @@ public class DataTest extends BaseRuntim
         criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
         result = BitCompositePkPeer.doSelect(criteria);
         assertEquals(1, result.size());
-        assertEquals("double true payload", result.get(0).getPayload());
+        assertEquals("true payload", result.get(0).getPayload());
         
         // check updating works
-        result.get(0).setPk2(Boolean.FALSE);
+        result.get(0).setPayload("true updated payload");
         result.get(0).save();
         
         criteria = new Criteria();
         criteria.and(BitCompositePkPeer.PK1, "true value");
-        criteria.and(BitCompositePkPeer.PK2, Boolean.FALSE);
+        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
         result = BitCompositePkPeer.doSelect(criteria);
         assertEquals(1, result.size());
-        assertEquals("double true payload", result.get(0).getPayload());
+        assertEquals("true updated payload", result.get(0).getPayload());
     }
 
     /**
@@ -746,41 +754,44 @@ public class DataTest extends BaseRuntim
         book.setIsbn("ISBN");
         book.save();
 
-        criteria.clear();
-        criteria.add(BookPeer.AUTHOR_ID, author.getAuthorId());
-        criteria.addJoin(AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID);
-        // The following where clause is not necessary from a sql point of view.
-        // However, it adds a second table to the where clauses of the
-        // criteria, so that it cannot be determined from the criteria alone
-        // which table should be deleted from. So this may cause data to
-        // disappear from both tables (TORQUE-93)
-        criteria.add(AuthorPeer.AUTHOR_ID, book.getAuthorId());
-        BookPeer.doDelete(criteria);
-        authorResult = AuthorPeer.doSelect(new Criteria());
-        bookResult = BookPeer.doSelect(new Criteria());
-        assertTrue("deleted not enough records",
-                bookResult.size() == 0);
-        assertTrue("delete also deleted objects in joined table",
-                authorResult.size() == 1);
-        
-        // recreate book, test whether deletes using joins work
-        book = new Book();
-        book.setTitle("title");
-        book.setAuthor(author);
-        book.setIsbn("ISBN");
-        book.save();
-
-        criteria.clear();
-        criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID);
-        criteria.add(AuthorPeer.NAME, author.getName());
-        BookPeer.doDelete(criteria);
-
-        authorResult = AuthorPeer.doSelect(new Criteria());
-        bookResult = BookPeer.doSelect(new Criteria());
-        assertTrue("deleted not enough records",
-                bookResult.size() == 0);
-        assertTrue("delete also deleted objects in joined table",
-                authorResult.size() == 1);
+//        criteria.clear();
+//        criteria.add(BookPeer.AUTHOR_ID, author.getAuthorId());
+//        criteria.addJoin(
+//                AuthorPeer.AUTHOR_ID,
+//                BookPeer.AUTHOR_ID,
+//                SqlEnum.INNER_JOIN);
+//        // The following where clause is not necessary from a sql point of view.
+//        // However, it adds a second table to the where clauses of the
+//        // criteria, so that it cannot be determined from the criteria alone
+//        // which table should be deleted from. So this may cause data to
+//        // disappear from both tables (TORQUE-93)
+//        criteria.add(AuthorPeer.AUTHOR_ID, book.getAuthorId());
+//        BookPeer.doDelete(criteria);
+//        authorResult = AuthorPeer.doSelect(new Criteria());
+//        bookResult = BookPeer.doSelect(new Criteria());
+//        assertTrue("deleted not enough records",
+//                bookResult.size() == 0);
+//        assertTrue("delete also deleted objects in joined table",
+//                authorResult.size() == 1);
+//        
+//        // recreate book, test whether deletes using joins work
+//        book = new Book();
+//        book.setTitle("title");
+//        book.setAuthor(author);
+//        book.setIsbn("ISBN");
+//        book.save();
+//
+//        criteria.clear();
+//        criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID);
+//        criteria.add(AuthorPeer.NAME, author.getName());
+//        BookPeer.doDelete(criteria);
+//
+//        authorResult = AuthorPeer.doSelect(new Criteria());
+//        bookResult = BookPeer.doSelect(new Criteria());
+//        assertTrue("deleted not enough records",
+//                bookResult.size() == 0);
+//        assertTrue("delete also deleted objects in joined table",
+//                authorResult.size() == 1);
     }
 
     /**
@@ -913,12 +924,12 @@ public class DataTest extends BaseRuntim
         // test double functions in select columns
         Criteria criteria = new Criteria();
         criteria.addSelectColumn("count(distinct(" + BookPeer.BOOK_ID + "))");
-        BookPeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null);
 
         // test qualifiers in function in select columns
         criteria = new Criteria();
         criteria.addSelectColumn("count(distinct " + BookPeer.BOOK_ID + ")");
-        BookPeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null);
     }
 
     /**
@@ -931,26 +942,55 @@ public class DataTest extends BaseRuntim
         
         criteria.addSelectColumn(BookPeer.BOOK_ID);
 
-        BasePeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null);
     }
 
     /**
-     * test the behaviour if a connection is supplied to access the database,
-     * but it is null. All methods on the user level should be able to
-     * handle this.
+     * Test the behaviour if a connection is supplied to access the database,
+     * but it is null. All methods on the user level should be fail
+     * because these methods will be only needed if a method should be executed
+     * in a transaction context. If one assumes that a transaction is open
+     * (connection is not null), but it is not (connection == null),
+     * it is a bad idea to silently start one as this behaviour is very
+     * difficult to tell from the correct one. A clean failure is much easier
+     * to test for.
      */
     public void testNullConnection() throws Exception
     {
-        Criteria criteria = new Criteria();
-        BookPeer.doSelectVillageRecords(criteria, null);
+        try
+        {
+            Criteria criteria = new Criteria();
+            BasePeer.doSelect(criteria, new IntegerMapper(), null, null);
+            fail("NullPointerException expected");
+        }
+        catch (NullPointerException e)
+        {
+            //expected
+        }
 
-        criteria = new Criteria();
-        criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
-        BookPeer.doDelete(criteria, null);
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
+            BookPeer.doDelete(criteria, null);
+            fail("NullPointerException expected");
+        }
+        catch (NullPointerException e)
+        {
+            //expected
+        }
 
-        Author author = new Author();
-        author.setName("name");
-        author.save((Connection) null);
+        try
+        {
+            Author author = new Author();
+            author.setName("name");
+            author.save((Connection) null);
+            fail("NullPointerException expected");
+        }
+        catch (NullPointerException e)
+        {
+            //expected
+        }
     }
 
     /**
@@ -1098,7 +1138,7 @@ public class DataTest extends BaseRuntim
         // using the test data from testJoins()
         Criteria criteria = new Criteria();
         criteria.addAscendingOrderByColumn(BookPeer.TITLE);
-        List books = MyBookPeer.doSelectJoinAuthor(criteria);
+        List<Book> books = MyBookPeer.doSelectJoinAuthor(criteria);
         assertTrue("books should contain 4 books but contains "
                 + books.size(), books.size() == 4);
         Book bookTwo = (Book) books.get(1);
@@ -1140,11 +1180,11 @@ public class DataTest extends BaseRuntim
         
         Criteria criteria =  new Criteria();
         criteria.add(APeer.A_ID, a.getAId());
-        List list = MyCPeer.doSelectJoinAllExceptA(criteria);
+        List<C> list = MyCPeer.doSelectJoinAllExceptA(criteria);
         assertTrue("list should contain 1 entry but contains "
                 + list.size(), list.size() == 1);
         
-        C c1 = (C)list.get(0);
+        C c1 = list.get(0);
         B b1 = c1.getB();
         RAb rab1 = c1.getRAb();
         
@@ -1467,7 +1507,7 @@ public class DataTest extends BaseRuntim
         // we need an additional column to select from,
         // to indicate the table we want use
         criteria.addSelectColumn(AuthorPeer.AUTHOR_ID);
-        BasePeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new DoNothingMapper(), null);
     }
 
     /**
@@ -1498,12 +1538,17 @@ public class DataTest extends BaseRuntim
         AuthorPeer.addSelectColumns(criteria);
         // basically a BaseBookPeer.setDbName(criteria);
         // and BasePeer.doSelect(criteria);
-        List villageRecords = BookPeer.doSelectVillageRecords(criteria);
-        Record record = (Record) villageRecords.get(0);
-        book = new Book();
-        BookPeer.populateObject(record, 1, book);
-        author = new Author();
-        AuthorPeer.populateObject(record, BookPeer.numColumns + 1, author);
+        CompositeMapper mapper = new CompositeMapper();
+        mapper.addMapper(new BookPeer.BookRecordMapper(), 0);
+        mapper.addMapper(
+                new AuthorPeer.AuthorRecordMapper(),
+                BookPeer.numColumns);
+        
+        List<List<Object>> queryResult
+                = BookPeer.doSelect(criteria, mapper, null);
+        List<Object> mappedRow = queryResult.get(0);
+        book = (Book) mappedRow.get(0);
+        author = (Author) mappedRow.get(1);
 
         if (book.getAuthorId() == author.getAuthorId())
         {
@@ -1554,6 +1599,7 @@ public class DataTest extends BaseRuntim
                 + 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();
@@ -1730,12 +1776,45 @@ public class DataTest extends BaseRuntim
 
         // read the BlobTests from the database
         // and check the values against the original values
-        List blobTestList = BlobTestPeer.doSelect(new Criteria());
+        List<BlobTest> blobTestList = BlobTestPeer.doSelect(new Criteria());
+        assertTrue("blobTestList should contain 1 object but contains "
+                + blobTestList.size(),
+                blobTestList.size() == 1);
+
+        BlobTest readBlobTest = blobTestList.get(0);
+        assertTrue("read and written blobs should be equal. "
+                + "Size of read blob is"
+                + readBlobTest.getBlobValue().length
+                + " size of written blob is "
+                + blobTest.getBlobValue().length,
+                Arrays.equals(
+                        blobTest.getBlobValue(),
+                        readBlobTest.getBlobValue()));
+
+        // test updating
+        blobTest = readBlobTest;
+        {
+            int length = 200000;
+            byte[] bytes = new byte[length];
+            StringBuffer chars = new StringBuffer();
+            String charTemplate = "9876543210abcdefghijklmnopqrstuvwxyz";
+            for (int i = 0; i < length; ++i)
+            {
+                bytes[i] = new Integer(i % 256).byteValue();
+                chars.append(charTemplate.charAt(i % charTemplate.length()));
+            }
+            blobTest.setBlobValue(bytes);
+        }
+        blobTest.save();
+
+        // read the BlobTests from the database
+        // and check the values against the updated values
+        blobTestList = BlobTestPeer.doSelect(new Criteria());
         assertTrue("blobTestList should contain 1 object but contains "
                 + blobTestList.size(),
                 blobTestList.size() == 1);
 
-        BlobTest readBlobTest = (BlobTest) blobTestList.get(0);
+        readBlobTest = blobTestList.get(0);
         assertTrue("read and written blobs should be equal. "
                 + "Size of read blob is"
                 + readBlobTest.getBlobValue().length
@@ -1790,16 +1869,43 @@ public class DataTest extends BaseRuntim
 
         // read the ClobTests from the database
         // and check the values against the original values
-        List clobTestList = ClobTestPeer.doSelect(new Criteria());
+        List<ClobTest> clobTestList = ClobTestPeer.doSelect(new Criteria());
+        assertTrue("clobTestList should contain 1 object but contains "
+                + clobTestList.size(),
+                clobTestList.size() == 1);
+
+        ClobTest readClobTest = clobTestList.get(0);
+        assertTrue("read and written clobs should be equal",
+                clobTest.getClobValue().equals(readClobTest.getClobValue()));
+
+        
+        // Test updating
+        clobTest = readClobTest;
+        {
+            int length = 20000;
+            StringBuffer chars = new StringBuffer();
+            String charTemplate = "0987654321abcdefghijklmnopqrstuvwxyz";
+            for (int i = 0; i < length; ++i)
+            {
+                 chars.append(charTemplate.charAt(i % charTemplate.length()));
+            }
+            clobTest.setClobValue(chars.toString());
+        }
+        clobTest.save();
+
+        // read the ClobTests from the database
+        // and check the values against the original values
+        clobTestList = ClobTestPeer.doSelect(new Criteria());
         assertTrue("clobTestList should contain 1 object but contains "
                 + clobTestList.size(),
                 clobTestList.size() == 1);
 
-        ClobTest readClobTest = (ClobTest) clobTestList.get(0);
+        readClobTest = clobTestList.get(0);
         assertTrue("read and written clobs should be equal",
                 clobTest.getClobValue().equals(readClobTest.getClobValue()));
     }
 
+
     /**
      * Test whether we can execute queries as prepared statements
      * @throws Exception
@@ -1827,7 +1933,9 @@ public class DataTest extends BaseRuntim
         criteria = new Criteria();
         criteria.add(LargePkPeer.LARGE_PK_ID, 2, Criteria.LESS_THAN);
         LargePkPeer.addSelectColumns(criteria);
-        List result = BasePeer.doPSSelect(criteria);
+        List<LargePk> result = BasePeer.doPSSelect(
+                criteria, new LargePkPeer.LargePkRecordMapper(),
+                LargePkPeer.getTableMap());
         assertTrue("Size of largePk list should be 1 but is "
                 + result.size(),
                 result.size() == 1);
@@ -2027,7 +2135,8 @@ public class DataTest extends BaseRuntim
                 InheritanceTestPeer.INHERITANCE_TEST);
         
         // Check that the class of the object is retained when loading
-        List inheritanceObjects = InheritanceTestPeer.doSelect(criteria);
+        List<InheritanceTest> inheritanceObjects 
+                = InheritanceTestPeer.doSelect(criteria);
         assertEquals(
                 InheritanceTest.class, 
                 inheritanceObjects.get(0).getClass());
@@ -2264,7 +2373,7 @@ public class DataTest extends BaseRuntim
      */
     static class MyBookPeer extends BookPeer
     {
-        public static List doSelectJoinAuthor(Criteria criteria)
+        public static List<Book> doSelectJoinAuthor(Criteria criteria)
                 throws TorqueException
         {
             return BookPeer.doSelectJoinAuthor(criteria);
@@ -2276,10 +2385,20 @@ public class DataTest extends BaseRuntim
      */
     static class MyCPeer extends CPeer
     {
-        public static List doSelectJoinAllExceptA(Criteria criteria)
+        public static List<C> doSelectJoinAllExceptA(Criteria criteria)
                 throws TorqueException
         {
             return CPeer.doSelectJoinAllExceptA(criteria);
         }
     }
+    
+    static class DoNothingMapper implements RecordMapper<Object>
+    {
+
+        public Object processRow(ResultSet resultSet, int rowOffset)
+                throws TorqueException
+        {
+            return null;
+        }
+    }
 }

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=1056899&r1=1056898&r2=1056899&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  9 09:52:45 2011
@@ -25,6 +25,8 @@ 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.map.TableMap;
+import org.apache.torque.om.mapper.ObjectListMapper;
 import org.apache.torque.test.Author;
 import org.apache.torque.test.AuthorPeer;
 import org.apache.torque.test.Book;
@@ -32,8 +34,6 @@ import org.apache.torque.test.BookPeer;
 import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.Criteria;
 
-import com.workingdogs.village.DataSetException;
-
 /**
  * Runtime tests to make sure that the code which is supplied
  * in the documentation actually works ;-)
@@ -224,13 +224,16 @@ public class DocsTest extends BaseRuntim
                 bookAuthors.size() == 3);
 
         // test explicit sql statements from details section
-        List result = null;
+        List<List<Object>> result = null;
         try
         {
-            result = BasePeer.executeQuery(
+            result = BasePeer.doSelect(
                     "SELECT book.* FROM book "
-                    + "INNER JOIN author "
-                    + "ON book.AUTHOR_ID=author.AUTHOR_ID");
+                        + "INNER JOIN author "
+                        + "ON book.AUTHOR_ID=author.AUTHOR_ID",
+                    new ObjectListMapper(),
+                    (TableMap) null,
+                    (String) null);
         }
         catch (Exception e)
         {
@@ -248,9 +251,12 @@ public class DocsTest extends BaseRuntim
         result = null;
         try
         {
-            result = BasePeer.executeQuery(
+            result = BasePeer.doSelect(
                     "SELECT book.* FROM book,author "
-                    + "WHERE book.AUTHOR_ID=author.AUTHOR_ID");
+                        + "WHERE book.AUTHOR_ID=author.AUTHOR_ID",
+                    new ObjectListMapper(),
+                    (TableMap) null,
+                    (String) null);
         }
         catch (Exception e)
         {
@@ -372,7 +378,7 @@ public class DocsTest extends BaseRuntim
     /**
      * Criteria Howto, section "subselects"
      */
-    public void testSubselects() throws TorqueException, DataSetException
+    public void testSubselects() throws TorqueException
     {
         DB adapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
         if (adapter instanceof DBMM)

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java?rev=1056899&r1=1056898&r2=1056899&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java Sun Jan  9 09:52:45 2011
@@ -151,14 +151,8 @@ public class DatabaseMapTest extends Bas
     }
 
     /**
-     * Test that XML table order is preserved in DatabaseMap objects.
+     * Check that the external schema tables are added to the database map.
      * <p>
-     * Assumptions:
-     * <ul>
-     * The default database is bookstore<br>
-     * TABLE_NAME1 is followed by TABLE_NAME2 in the array<br>
-     * </ul>
-     * 
      * @throws TorqueException
      */
     public void testExternalSchemaTables() throws TorqueException

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=1056899&r1=1056898&r2=1056899&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  9 09:52:45 2011
@@ -87,8 +87,7 @@ public class LargeSelectTest extends Bas
      */
     public void testCriteria() throws TorqueException
     {
-        List result = null;
-        result = AuthorPeer.doSelect(criteria);
+        List<Author> result = AuthorPeer.doSelect(criteria);
         assertEquals("Selected rows", TEST_ROWS, result.size());
     }
 
@@ -100,8 +99,9 @@ public class LargeSelectTest extends Bas
         criteria.setLimit(1);
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE,
-                    "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -117,8 +117,9 @@ public class LargeSelectTest extends Bas
         criteria.setOffset(1);
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE,
-                    "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -133,7 +134,9 @@ public class LargeSelectTest extends Bas
     {
         try
         {
-            new LargeSelect(criteria, 0, "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, 0,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -148,8 +151,9 @@ public class LargeSelectTest extends Bas
     {
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE, 0,
-                    "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE, 0,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -164,8 +168,9 @@ public class LargeSelectTest extends Bas
     {
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE,
-                    "org.apache.torque.test.Author");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE,
+                    "org.apache.torque.test.Author",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -197,13 +202,15 @@ public class LargeSelectTest extends Bas
      */
     public void testLargeSelect() throws TorqueException
     {
-        LargeSelect ls = new LargeSelect(criteria, TEST_PAGE_SIZE,
-                "org.apache.torque.test.AuthorPeer");
+        LargeSelect<Author> ls = new LargeSelect<Author>(
+                criteria,
+                TEST_PAGE_SIZE,
+                "org.apache.torque.test.AuthorPeer",
+                new AuthorPeer.AuthorRecordMapper());
 
         assertEquals("Page size", TEST_PAGE_SIZE, ls.getPageSize());
         assertTrue("Paginated", ls.getPaginated());
 
-
         // Page 0
         assertEquals("Current page number", 0, ls.getCurrentPageNumber());
         assertFalse("Previous results available", ls.getPreviousResultsAvailable());
@@ -217,7 +224,7 @@ public class LargeSelectTest extends Bas
         assertEquals("Page progress text", "0 of &gt; 0", ls.getPageProgressText());
         assertEquals("Record progress text", "0 - 0 of &gt; 0", ls.getRecordProgressText());
 
-        List results = ls.getNextResults();
+        List<Author> results = ls.getNextResults();
         // Page 1
         assertEquals("results.size()", TEST_PAGE_SIZE, results.size());
         assertEquals("Current page number", 1, ls.getCurrentPageNumber());
@@ -296,7 +303,7 @@ public class LargeSelectTest extends Bas
         assertEquals("Page progress text", "2 of 9", ls.getPageProgressText());
         assertEquals("Record progress text", "10 - 18 of 81", ls.getRecordProgressText());
 
-        List sameResults = ls.getCurrentPageResults();
+        List<Author> sameResults = ls.getCurrentPageResults();
         // Page 2
         assertSame("Same results", results, sameResults);
 
@@ -324,11 +331,14 @@ public class LargeSelectTest extends Bas
         // Alter criteria to retrieve only one row
         criteria.add(AuthorPeer.AUTHOR_ID, firstAuthorId);
 
-        LargeSelect ls = new LargeSelect(criteria, TEST_PAGE_SIZE,
-                "org.apache.torque.test.AuthorPeer");
+        LargeSelect<Author> ls = new LargeSelect<Author>(
+                criteria, 
+                TEST_PAGE_SIZE,
+                "org.apache.torque.test.AuthorPeer",
+                new AuthorPeer.AuthorRecordMapper());
 
         // Page 1
-        List results = ls.getNextResults();
+        List<Author> results = ls.getNextResults();
         assertTrue("Totals finalised", ls.getTotalsFinalized());
         assertFalse("Paginated", ls.getPaginated());
         assertEquals("results.size()", 1, results.size());
@@ -350,8 +360,11 @@ public class LargeSelectTest extends Bas
      */
     public void testInvalidateResult() throws Exception
     {
-        LargeSelect ls = new LargeSelect(criteria, TEST_PAGE_SIZE,
-                "org.apache.torque.test.AuthorPeer");
+        LargeSelect<Author> ls = new LargeSelect<Author>(
+                criteria,
+                TEST_PAGE_SIZE,
+                "org.apache.torque.test.AuthorPeer",
+                new AuthorPeer.AuthorRecordMapper());
 
         assertEquals("Page size", TEST_PAGE_SIZE, ls.getPageSize());
         assertTrue("Paginated", ls.getPaginated());
@@ -369,7 +382,7 @@ public class LargeSelectTest extends Bas
         assertEquals("Page progress text", "0 of &gt; 0", ls.getPageProgressText());
         assertEquals("Record progress text", "0 - 0 of &gt; 0", ls.getRecordProgressText());
 
-        List results = ls.getNextResults();
+        List<Author> results = ls.getNextResults();
         // Page 1
         assertEquals("results.size()", TEST_PAGE_SIZE, results.size());
         assertEquals("Current page number", 1, ls.getCurrentPageNumber());



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