db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1028130 [1/6] - in /db/torque/torque4/branches/trunk-without-village: torque-runtime/ 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/torque/om...
Date Wed, 27 Oct 2010 22:52:18 GMT
Author: tfischer
Date: Wed Oct 27 22:52:15 2010
New Revision: 1028130

URL: http://svn.apache.org/viewvc?rev=1028130&view=rev
Log:
village removed.

Added:
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/BigDecimalMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/CompositeMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/IntegerMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/LongMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/ObjectListMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/RecordMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/StringMapper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/package.html
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/ColumnValues.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/JdbcTypedValue.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/DatabaseChildElementName.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/typemapping/ResultSetGetter.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SqlTypeWithJdbcType.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/createDbObjectInstance.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildColumnValues.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/createDbObjectInstanceFromInheritance.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/dbObjectFieldGetter.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/recordmapper/recordMapper.vm
Removed:
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/VillageUtils.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectVillageRecords.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObject.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/populateObjects.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/row2Object.vm
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/engine/database/transform/
Modified:
    db/torque/torque4/branches/trunk-without-village/torque-runtime/pom.xml
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/AutoIncrementIdGenerator.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/SequenceIdGenerator.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/BooleanKey.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/DateKey.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/NumberKey.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ObjectKey.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/StringKey.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/Query.java
    db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/pom.xml
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/SchemaTypeHelper.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FindHelper.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/LoadExternalSchemaTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/TableAttributeName.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/typemapping/TypeMap.java
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/control.xml
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/dbObject.xml
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/general.xml
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/outlets/peer.xml
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/bean/objectBeanMethods.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/copyMethods.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getByNameMethods.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/primaryKeyMethods.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/saveMethods.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/toString.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/general/setterMethodEnd.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/manager/base/baseManager.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapBuilder/doBuild.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/mapInit/baseMapInit.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/basePeer.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildCriteria.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/buildSelectCriteria.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/dbObjectClassConstants.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doDelete.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doInsert.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelect.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoin.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doSelectJoinAllExcept.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/doUpdate.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/getOMClass.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/resultSet2Objects.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/derby/table.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/table.vm
    db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/transformer/om/OMTableTransformer.properties
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DocsTest.java
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/pom.xml?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/pom.xml (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/pom.xml Wed Oct 27 22:52:15 2010
@@ -111,25 +111,6 @@
       <version>1.3</version>
     </dependency>
 
-    <!--dependency>
-      <groupId>javax.sql</groupId>
-      <artifactId>jdbc-stdext</artifactId>
-      <version>2.0</version>
-    </dependency-->
-
-    <!--dependency>
-      <groupId>javax.naming</groupId>
-      <artifactId>jndi</artifactId>
-      <version>1.2.1</version>
-    </dependency-->
-
-    <dependency>
-      <groupId>org.apache.torque</groupId>
-      <artifactId>village</artifactId>
-      <version>3.3</version>
-      <type>jar</type>
-    </dependency>
-
     <dependency>
       <groupId>xerces</groupId>
       <artifactId>xercesImpl</artifactId>

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/map/TableMap.java Wed Oct 27 22:52:15 2010
@@ -20,12 +20,15 @@ package org.apache.torque.map;
  */
 
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.StringTokenizer;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.IDMethod;
 import org.apache.torque.oid.IdGenerator;
 
@@ -815,4 +818,38 @@ public class TableMap implements IDMetho
     {
         return optionsMap.get(key);
     }
+
+    /**
+     * Returns the single primary key of this table, if it exists
+     *
+     * @return the single primary key column.
+     *
+     * @throws TorqueException If the table has no primary key
+     *         or if the table has multiple primary keys.
+     */
+    public ColumnMap getPrimaryKey()
+            throws TorqueException
+    {
+        Set<ColumnMap> result = new HashSet<ColumnMap>();
+
+        for (ColumnMap column : columns.values())
+        {
+            if (column.isPrimaryKey())
+            {
+                result.add(column);
+            }
+        }
+        if (result.isEmpty())
+        {
+            throw new TorqueException("getPrimaryKey(): Table " + tableName
+                    + "has no primary key.");
+        }
+        if (result.size() > 1)
+        {
+            throw new TorqueException("getPrimaryKey(): Table " + tableName
+                    + "has more than one primary key.");
+        }
+        return result.iterator().next();
+    }
+
 }

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/AutoIncrementIdGenerator.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/AutoIncrementIdGenerator.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/AutoIncrementIdGenerator.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/AutoIncrementIdGenerator.java Wed Oct 27 22:52:15 2010
@@ -21,11 +21,17 @@ package org.apache.torque.oid;
 
 import java.math.BigDecimal;
 import java.sql.Connection;
+import java.util.List;
+
+import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.DB;
+import org.apache.torque.om.mapper.BigDecimalMapper;
+import org.apache.torque.om.mapper.IntegerMapper;
+import org.apache.torque.om.mapper.LongMapper;
+import org.apache.torque.om.mapper.RecordMapper;
+import org.apache.torque.om.mapper.StringMapper;
+import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.SQLBuilder;
-import com.workingdogs.village.QueryDataSet;
-import com.workingdogs.village.Record;
-import com.workingdogs.village.Value;
 
 /**
  * This generator works with databases that have an sql syntax that
@@ -58,60 +64,70 @@ public class AutoIncrementIdGenerator im
     /**
      * Returns the last ID used by this connection.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
-     * @return An int with the value for the id.
-     * @exception Exception Database error.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the table on which the last insert occured.
+     *
+     * @return An int with the last value auto-incremented as a
+     *         result of an insert.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public int getIdAsInt(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asInt();
+        return getId(connection, keyInfo, new IntegerMapper());
     }
 
     /**
      * Returns the last ID used by this connection.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
-     * @return A long with the value for the id.
-     * @exception Exception Database error.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the table on which the last insert occured.
+     *
+     * @return A long with the last value auto-incremented as a
+     *         result of an insert.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public long getIdAsLong(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asLong();
+        return getId(connection, keyInfo, new LongMapper());
     }
 
     /**
      * Returns the last ID used by this connection.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the table on which the last insert occured.
+     *
      * @return A BigDecimal with the last value auto-incremented as a
-     * result of an insert.
-     * @exception Exception Database error.
+     *         result of an insert.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public BigDecimal getIdAsBigDecimal(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asBigDecimal();
+        return getId(connection, keyInfo, new BigDecimalMapper());
     }
 
 
     /**
      * Returns the last ID used by this connection.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the table on which the last insert occured.
+     *
      * @return A String with the last value auto-incremented as a
-     * result of an insert.
-     * @exception Exception Database error.
+     *         result of an insert.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public String getIdAsString(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asString();
+        return getId(connection, keyInfo, new StringMapper());
     }
 
     /**
@@ -150,31 +166,22 @@ public class AutoIncrementIdGenerator im
      *
      * @param connection A Connection.
      * @param keyInfo an Object that contains additional info.
-     * @return A Village Value with the last value auto-incremented as a
-     * result of an insert.
-     * @exception Exception Database error.
+     * @param mapper The RecordMapper that maps from a ResultSet to the
+     *        appropriate java object.
+     *
+     * @return The generated id.
+     * @exception TorqueException if a database error occurs.
      */
-    private Value getIdAsVillageValue(Connection connection, Object keyInfo)
-        throws Exception
+    private <T> T getId(
+                Connection connection,
+                Object keyInfo,
+                RecordMapper<T> mapper)
+            throws TorqueException
     {
         String tableName = SQLBuilder.getFullTableName(String.valueOf(keyInfo), name);
-        String idSQL = dbAdapter.getIDMethodSQL(tableName);
-        Value id = null;
-        QueryDataSet qds = null;
-        try
-        {
-            qds = new QueryDataSet(connection, idSQL);
-            qds.fetchRecords(1);
-            Record rec = qds.getRecord(0);
-            id = rec.getValue(1);
-        }
-        finally
-        {
-            if (qds != null)
-            {
-                qds.close();
-            }
-        }
-        return id;
+        String idSql = dbAdapter.getIDMethodSQL(tableName);
+
+        List<T> result = BasePeer.doSelect(idSql, mapper, null, connection);
+        return result.get(0);
     }
 }

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/SequenceIdGenerator.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/SequenceIdGenerator.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/SequenceIdGenerator.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/oid/SequenceIdGenerator.java Wed Oct 27 22:52:15 2010
@@ -21,17 +21,18 @@ package org.apache.torque.oid;
 
 import java.math.BigDecimal;
 import java.sql.Connection;
+import java.util.List;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
+import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.DB;
+import org.apache.torque.om.mapper.BigDecimalMapper;
+import org.apache.torque.om.mapper.IntegerMapper;
+import org.apache.torque.om.mapper.LongMapper;
+import org.apache.torque.om.mapper.RecordMapper;
+import org.apache.torque.om.mapper.StringMapper;
+import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.SQLBuilder;
 
-import com.workingdogs.village.QueryDataSet;
-import com.workingdogs.village.Record;
-import com.workingdogs.village.Value;
-
 /**
  * This generator works with databases that have an sql syntax for
  * getting an id prior to inserting a row into the database.
@@ -41,9 +42,6 @@ import com.workingdogs.village.Value;
  */
 public class SequenceIdGenerator implements IdGenerator
 {
-    /** The log. */
-    private static Log log = LogFactory.getLog(SequenceIdGenerator.class);
-
     /** the adapter that knows the correct sql syntax */
     private DB dbAdapter;
 
@@ -65,57 +63,65 @@ public class SequenceIdGenerator impleme
     /**
      * Retrieves an id as an int.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the sequence, not null.
+     *
      * @return An int with the value for the id.
-     * @exception Exception Database error.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public int getIdAsInt(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asInt();
+        return getId(connection, keyInfo, new IntegerMapper());
     }
 
     /**
      * Retrieves an id as an long.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the sequence, not null.
+     *
      * @return A long with the value for the id.
-     * @exception Exception Database error.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public long getIdAsLong(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asLong();
+        return getId(connection, keyInfo, new LongMapper());
     }
 
     /**
      * Retrieves an id as a BigDecimal.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
-     * @return A BigDecimal id
-     * @exception Exception Database error.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the sequence, not null.
+     *
+     * @return A BigDecimal id.
+     *
+     * @exception TorqueException if a database error occurs.
      */
     public BigDecimal getIdAsBigDecimal(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asBigDecimal();
+        return getId(connection, keyInfo, new BigDecimalMapper());
     }
 
     /**
      * Retrieves an id as an String.
      *
-     * @param connection A Connection.
-     * @param keyInfo an Object that contains additional info.
-     * @return A String id
-     * @exception Exception Database error.
+     * @param connection The database connection to read the sequence, not null.
+     * @param keyInfo the name of the sequence, not null.
+     *
+     * @return A String id.
+     *
+     * @throws TorqueException if a database error occurs.
      */
     public String getIdAsString(Connection connection, Object keyInfo)
-        throws Exception
+        throws TorqueException
     {
-        return getIdAsVillageValue(connection, keyInfo).asString();
+        return getId(connection, keyInfo, new StringMapper());
     }
 
     /**
@@ -150,35 +156,27 @@ public class SequenceIdGenerator impleme
     }
 
     /**
-     * Retrieves an id as a Village Value.
+     * Retrieves an id from a sequence.
      *
      * @param connection A Connection.
      * @param keyInfo an Object that contains additional info.
-     * @return A Village Value id.
-     * @exception Exception Database error.
+     * @param mapper The RecordMapper that maps from a ResultSet to the
+     *        appropriate java object.
+     *
+     * @return The generated id.
+     * @throws TorqueException if a database error occurs.
      */
-    private Value getIdAsVillageValue(Connection connection, Object keyInfo)
-        throws Exception
+    private <T> T getId(
+                Connection connection,
+                Object keyInfo,
+                RecordMapper<T> mapper)
+            throws TorqueException
     {
-        String sequenceName = SQLBuilder.getFullTableName(String.valueOf(keyInfo), name);
+        String sequenceName
+                = SQLBuilder.getFullTableName(String.valueOf(keyInfo), name);
         String idSql = dbAdapter.getIDMethodSQL(sequenceName);
-        if (log.isDebugEnabled())
-        {
-            log.debug(idSql);
-        }
-
-        // Execute the query.
-        QueryDataSet qds = new QueryDataSet(connection, idSql);
-        Record rec;
-        try
-        {
-            qds.fetchRecords(1);
-            rec = qds.getRecord(0);  // Records are 0 based.
-        }
-        finally
-        {
-            qds.close();
-        }
-        return rec.getValue(1); // Values are 1 based.
+
+        List<T> result = BasePeer.doSelect(idSql, mapper, null, connection);
+        return result.get(0);
     }
 }

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/BooleanKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/BooleanKey.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/BooleanKey.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/BooleanKey.java Wed Oct 27 22:52:15 2010
@@ -1,5 +1,7 @@
 package org.apache.torque.om;
 
+import java.sql.Types;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -124,6 +126,17 @@ public class BooleanKey extends SimpleKe
     }
 
     /**
+     * Returns the JDBC type of the key
+     * as defined in <code>java.sql.Types</code>.
+     *
+     * @return <code>Types.BIT</code>.
+     */
+    public int getJdbcType()
+    {
+        return Types.BIT;
+    }
+
+    /**
      * keyObj is equal to this StringKey if keyObj is a StringKey or String
      * that contains the same information this key contains.  Two ObjectKeys
      * that both contain null values are not considered equal.

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java Wed Oct 27 22:52:15 2010
@@ -19,6 +19,7 @@ package org.apache.torque.om;
  * under the License.
  */
 
+import java.sql.Types;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -170,6 +171,17 @@ public class ComboKey extends ObjectKey
     }
 
     /**
+     * Returns the JDBC type of the key
+     * as defined in <code>java.sql.Types</code>.
+     *
+     * @return <code>Types.ARRAY</code>.
+     */
+    public int getJdbcType()
+    {
+        return Types.ARRAY;
+    }
+
+    /**
      * This method will return true if the conditions for a looseEquals
      * are met and in addition no parts of the keys are null.
      *

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/DateKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/DateKey.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/DateKey.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/DateKey.java Wed Oct 27 22:52:15 2010
@@ -19,6 +19,7 @@ package org.apache.torque.om;
  * under the License.
  */
 
+import java.sql.Types;
 import java.util.Date;
 
 /**
@@ -110,6 +111,17 @@ public class DateKey extends SimpleKey
     }
 
     /**
+     * Returns the JDBC type of the key
+     * as defined in <code>java.sql.Types</code>.
+     *
+     * @return <code>Types.TIMESTAMP</code>.
+     */
+    public int getJdbcType()
+    {
+        return Types.TIMESTAMP;
+    }
+
+    /**
      * Access the underlying Date object.
      *
      * @return a <code>Date</code> value

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/NumberKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/NumberKey.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/NumberKey.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/NumberKey.java Wed Oct 27 22:52:15 2010
@@ -20,6 +20,7 @@ package org.apache.torque.om;
  */
 
 import java.math.BigDecimal;
+import java.sql.Types;
 
 /**
  * This class can be used as an ObjectKey to uniquely identify an
@@ -165,6 +166,17 @@ public class NumberKey extends SimpleKey
     }
 
     /**
+     * Returns the JDBC type of the key
+     * as defined in <code>java.sql.Types</code>.
+     *
+     * @return <code>Types.NUMERIC</code>.
+     */
+    public int getJdbcType()
+    {
+        return Types.NUMERIC;
+    }
+
+    /**
      * Access the underlying BigDecimal object.
      *
      * @return a <code>BigDecimal</code> value

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ObjectKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ObjectKey.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ObjectKey.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/ObjectKey.java Wed Oct 27 22:52:15 2010
@@ -72,6 +72,14 @@ public abstract class ObjectKey implemen
     }
 
     /**
+     * Returns the JDBC type of the key
+     * as defined in <code>java.sql.Types</code>.
+     *
+     * @return the JDBC type of the key.
+     */
+    public abstract int getJdbcType();
+
+    /**
      * Appends a String representation of the key to a buffer.
      *
      * @param sb a <code>StringBuffer</code>

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/StringKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/StringKey.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/StringKey.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/StringKey.java Wed Oct 27 22:52:15 2010
@@ -1,5 +1,7 @@
 package org.apache.torque.om;
 
+import java.sql.Types;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -107,6 +109,17 @@ public class StringKey extends SimpleKey
     }
 
     /**
+     * Returns the JDBC type of the key
+     * as defined in <code>java.sql.Types</code>.
+     *
+     * @return <code>Types.VARCHAR</code>.
+     */
+    public int getJdbcType()
+    {
+        return Types.VARCHAR;
+    }
+
+    /**
      * keyObj is equal to this StringKey if keyObj is a StringKey or String
      * that contains the same information this key contains.  Two ObjectKeys
      * that both contain null values are not considered equal.

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/BigDecimalMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/BigDecimalMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/BigDecimalMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/BigDecimalMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,72 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.math.BigDecimal;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Maps a database record to a BigDecimal.
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public class BigDecimalMapper implements RecordMapper<BigDecimal>
+{
+    /** The internal offset for the mapper. */
+    private int internalOffset;
+
+    /**
+     * Constructs a BigDecimalMapper with an offset of 0.
+     */
+    public BigDecimalMapper()
+    {
+        internalOffset = 0;
+    }
+
+    /**
+     * Constructs a BigDecimalMapper with the given offset.
+     *
+     * @param offset the additional offset (0 based).
+     */
+    public BigDecimalMapper(int offset)
+    {
+        this.internalOffset = offset;
+    }
+
+    public BigDecimal processRow(
+                ResultSet resultSet,
+                int rowOffset)
+            throws TorqueException
+    {
+        try
+        {
+            return resultSet.getBigDecimal(rowOffset + internalOffset + 1);
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(
+                    "Result could not be mapped to a getBigDecimal",
+                    e);
+        }
+    }
+}

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/CompositeMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/CompositeMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/CompositeMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/CompositeMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,118 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Uses a list of mappers to map a database record to a list of objects.
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public class CompositeMapper implements RecordMapper<List<Object>>
+{
+    /**
+     * All mappers which should be appliead to a result set, combined with
+     * their individual offset.
+     */
+    private List<MapperWithOffset> mapperList
+        = new ArrayList<MapperWithOffset>();
+
+    /**
+     * Adds a new mapper to be applied to a result set.
+     *
+     * @param mapper the mapper.
+     * @param offset the offset of the mapper within this mapper, 0 based.
+     */
+    public void addMapper(RecordMapper<?> mapper, int offset)
+    {
+        mapperList.add(new MapperWithOffset(mapper, offset));
+    }
+
+    /**
+     * Maps the current row in the result Set by applying all known mappers
+     * and putting the result of each mapper in the result list.
+     *
+     * @param resultSet the result set to map, not null.
+     * @param offset the total offset of this mapper within the result set.
+     *
+     * @return a list of mapped objects in the same order as the mappers
+     *         were ordered, not null.
+     */
+    public List<Object> processRow(ResultSet resultSet, int offset)
+        throws TorqueException
+    {
+        List<Object> result = new ArrayList<Object>(mapperList.size());
+        for (MapperWithOffset mapperWithOffset : mapperList)
+        {
+            int totalOffset = offset +  mapperWithOffset.getOffset();
+            RecordMapper<?> mapper = mapperWithOffset.getMapper();
+            result.add(mapper.processRow(resultSet, totalOffset));
+        }
+        return result;
+    }
+
+    /** Contains a row mapper plus the internal offset of the mapper. */
+    private static class MapperWithOffset
+    {
+        /** The row mapper. */
+        private RecordMapper<?> mapper;
+
+        /** The offset. */
+        private int offset;
+
+        /**
+         * Constructor.
+         *
+         * @param mapper the mapper, not null.
+         * @param offset the internal offset of the mapper.
+         */
+        public MapperWithOffset(RecordMapper<?> mapper, int offset)
+        {
+            this.mapper = mapper;
+            this.offset = offset;
+        }
+
+        /**
+         * Returns the mapper.
+         *
+         * @return the mapper.
+         */
+        public RecordMapper<?> getMapper()
+        {
+            return mapper;
+        }
+
+        /**
+         * Returns the offset.
+         *
+         * @return the offset.
+         */
+        public int getOffset()
+        {
+            return offset;
+        }
+    }
+}
+

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/IntegerMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/IntegerMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/IntegerMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/IntegerMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,71 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Maps a database record to a Integer.
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public class IntegerMapper implements RecordMapper<Integer>
+{
+    /** The internal offset for the mapper. */
+    private int internalOffset;
+
+    /**
+     * Constructs a IntegerMapper with an offset of 0.
+     */
+    public IntegerMapper()
+    {
+        internalOffset = 0;
+    }
+
+    /**
+     * Constructs a IntegerMapper with the given offset.
+     *
+     * @param offset the additional offset (0 based).
+     */
+    public IntegerMapper(int offset)
+    {
+        this.internalOffset = offset;
+    }
+
+    public Integer processRow(
+                ResultSet resultSet,
+                int rowOffset)
+            throws TorqueException
+    {
+        try
+        {
+            return Integer.valueOf(
+                    resultSet.getInt(rowOffset + internalOffset + 1));
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException("Result could not be mapped to a Integer",
+                    e);
+        }
+    }
+}

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/LongMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/LongMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/LongMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/LongMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,71 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Maps a database record to a Long.
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public class LongMapper implements RecordMapper<Long>
+{
+    /** The internal offset for the mapper. */
+    private int internalOffset;
+
+    /**
+     * Constructs a LongMapper with an offset of 0.
+     */
+    public LongMapper()
+    {
+        internalOffset = 0;
+    }
+
+    /**
+     * Constructs a LongMapper with the given offset.
+     *
+     * @param offset the additional offset (0 based).
+     */
+    public LongMapper(int offset)
+    {
+        this.internalOffset = offset;
+    }
+
+    public Long processRow(
+                ResultSet resultSet,
+                int rowOffset)
+            throws TorqueException
+    {
+        try
+        {
+            return Long.valueOf(
+                    resultSet.getLong(rowOffset + internalOffset + 1));
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException("Result could not be mapped to a Long",
+                    e);
+        }
+    }
+}

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/ObjectListMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/ObjectListMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/ObjectListMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/ObjectListMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,256 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.io.InputStream;
+import java.io.Reader;
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Maps a record to a list of objects.
+ * Either the database driver decides which object type is appropriate
+ * for each column, or a list of classes can be defined.
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public class ObjectListMapper implements RecordMapper<List<Object>>
+{
+    /**
+     * Contains the classes to which the columns are mapped.
+     * The size of the list determines how many columns are read.
+     */
+    private List<Class<?>> convertClasses = null;
+
+    /**
+     * Constructor. Determines the number of columns to map from the
+     * result set's metadata (this may issue additional database queries).
+     * The classes the result columns are mapped to are determined by the
+     * database driver.
+     */
+    public ObjectListMapper()
+    {
+    }
+
+    /**
+     * Constructor which sets the number of columns to map.
+     * The classes the result columns are mapped to are determined by the
+     * database driver.
+     *
+     * @param numberOfColumnsToMap how many columns should be mapped,
+     *        or -1 to determine the number of columns to map from the
+     *        result set's metadata (this may issue
+     *        additional database queries).
+     */
+    public ObjectListMapper(int numberOfColumnsToMap)
+    {
+        this.convertClasses = new ArrayList<Class<?>>(numberOfColumnsToMap);
+        if (numberOfColumnsToMap != -1)
+        {
+            for (int i = 0; i < numberOfColumnsToMap; ++i)
+            {
+                convertClasses.add(Object.class);
+            }
+        }
+    }
+
+    /**
+     * Constructor which determines the number of columns to map
+     * and the classes the result columns are mapped to.
+     *
+     * @param convertClasses the classes to which the columns should be mapped.
+     *        The first column is mapped to the first class in the list and
+     *        so on. May be null, in which case the number of columns to map
+     *        and the mapped to classes are determined by the database driver.
+     *        Known classes are: java.lang.reflect.Array, java.math.BigDecimal,
+     *        java.io.InputStream, java.sql. Blob, Boolean, Byte, byte[],
+     *        java.io.Reader, java.sql.Clob, java.sql.Date, Double, Float,
+     *        Integer, Long, Object (i.e. let the database driver decide
+     *        which class is returned), java.sql.Ref, Short, String,
+     *        java.sql.Time, java.sql.Timestamp and java.net.URL.
+     */
+    public ObjectListMapper(List<Class<?>> convertClasses)
+    {
+        if (convertClasses != null)
+        {
+            this.convertClasses = new ArrayList<Class<?>>(convertClasses);
+        }
+    }
+
+    /**
+     * Maps the current row in the result set by reading all columns from
+     * offset on to the end of the row and store an object for each column
+     * in the result.
+     *
+     * @param resultSet the result set to map, not null.
+     * @param offset the offset of this mapper within the result set.
+     *
+     * @return a list of mapped objects in the same order as the mappers
+     *         were ordered, not null.
+     *
+     * @throws TorqueException if retrieving column values from the result set
+     *         fails or if the number of available columns cannot be determined
+     *         from the result set.
+     */
+    public List<Object> processRow(ResultSet resultSet, int offset)
+        throws TorqueException
+    {
+        try
+        {
+            int currentNumberOfColumnsToMap;
+            if (convertClasses != null)
+            {
+                currentNumberOfColumnsToMap = convertClasses.size();
+            }
+            else
+            {
+                int resultSetLength = resultSet.getMetaData().getColumnCount();
+                currentNumberOfColumnsToMap = resultSetLength - offset;
+            }
+
+            List<Object> result
+                    = new ArrayList<Object>(currentNumberOfColumnsToMap);
+            for (int i = 0; i < currentNumberOfColumnsToMap; ++i)
+            {
+                Class<?> mapClass;
+                if (convertClasses != null)
+                {
+                    mapClass = convertClasses.get(i);
+                }
+                else
+                {
+                    mapClass = Object.class;
+                }
+                Object columnValue;
+                int columnIndex = i + offset + 1;
+                if (mapClass.equals(Array.class))
+                {
+                    columnValue = resultSet.getArray(columnIndex);
+                }
+                else if (mapClass.equals(BigDecimal.class))
+                {
+                    columnValue = resultSet.getBigDecimal(columnIndex);
+                }
+                else if (mapClass.equals(InputStream.class))
+                {
+                    columnValue = resultSet.getBinaryStream(columnIndex);
+                }
+                else if (mapClass.equals(Blob.class))
+                {
+                    columnValue = resultSet.getBlob(columnIndex);
+                }
+                else if (mapClass.equals(Boolean.class))
+                {
+                    columnValue = resultSet.getBoolean(columnIndex);
+                }
+                else if (mapClass.equals(Byte.class))
+                {
+                    columnValue = resultSet.getByte(columnIndex);
+                }
+                else if (mapClass.equals(byte[].class))
+                {
+                    columnValue = resultSet.getBytes(columnIndex);
+                }
+                else if (mapClass.equals(Reader.class))
+                {
+                    columnValue = resultSet.getCharacterStream(columnIndex);
+                }
+                else if (mapClass.equals(Clob.class))
+                {
+                    columnValue = resultSet.getClob(columnIndex);
+                }
+                else if (mapClass.equals(Date.class))
+                {
+                    columnValue = resultSet.getDate(columnIndex);
+                }
+                else if (mapClass.equals(Double.class))
+                {
+                    columnValue = resultSet.getDouble(columnIndex);
+                }
+                else if (mapClass.equals(Float.class))
+                {
+                    columnValue = resultSet.getFloat(columnIndex);
+                }
+                else if (mapClass.equals(Integer.class))
+                {
+                    columnValue = resultSet.getInt(columnIndex);
+                }
+                else if (mapClass.equals(Long.class))
+                {
+                    columnValue = resultSet.getLong(columnIndex);
+                }
+                else if (mapClass.equals(Object.class))
+                {
+                    columnValue = resultSet.getObject(columnIndex);
+                }
+                else if (mapClass.equals(Ref.class))
+                {
+                    columnValue = resultSet.getRef(columnIndex);
+                }
+                else if (mapClass.equals(Short.class))
+                {
+                    columnValue = resultSet.getShort(columnIndex);
+                }
+                else if (mapClass.equals(String.class))
+                {
+                    columnValue = resultSet.getString(columnIndex);
+                }
+                else if (mapClass.equals(Time.class))
+                {
+                    columnValue = resultSet.getTime(columnIndex);
+                }
+                else if (mapClass.equals(Timestamp.class))
+                {
+                    columnValue = resultSet.getTimestamp(columnIndex);
+                }
+                else if (mapClass.equals(URL.class))
+                {
+                    columnValue = resultSet.getURL(columnIndex);
+                }
+                else
+                {
+                    throw new IllegalArgumentException(
+                            "Unknown convertClass " + mapClass.getName()
+                            + " at position " + i);
+                }
+                result.add(columnValue);
+            }
+            return result;
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
+    }
+}
+

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/RecordMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/RecordMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/RecordMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/RecordMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,54 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.sql.ResultSet;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Maps an object to a database record and back.
+ * This means that the object can be read from a database resultSet
+ * and that it can produce PreparedStatements which insert or update
+ * the record in the the database.
+ *
+ * @param <T> the class to map from and to a database record
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public interface RecordMapper<T>
+{
+    /**
+     * Constructs the object from the current row in the resultSet.
+     * Implementing methods can be sure that the resultSet contains a row,
+     * but they must only operate on the current row, i.e they must not call
+     * resultSet.next().
+     *
+     * @param resultSet the resultSet to operate on, already pointing
+     *        to the correct row. Not null.
+     * @param a possible offset in the rows to be considered
+     *        (if previous rows contain other objects).
+     *
+     * @return the mapped object, not null.
+     *
+     * @throws TorqueException when the mapping fails.
+     */
+    T processRow(ResultSet resultSet, int rowOffset) throws TorqueException;
+}

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/StringMapper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/StringMapper.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/StringMapper.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/StringMapper.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,70 @@
+package org.apache.torque.om.mapper;
+
+/*
+ * 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.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.torque.TorqueException;
+
+/**
+ * Maps a database record to a String.
+ *
+ * @version $Id: BaseObject.java 516325 2007-03-09 08:03:53Z seade $
+ */
+public class StringMapper implements RecordMapper<String>
+{
+    /** The internal offset for the mapper. */
+    private int internalOffset;
+
+    /**
+     * Constructs a StringMapper with an offset of 0.
+     */
+    public StringMapper()
+    {
+        internalOffset = 0;
+    }
+
+    /**
+     * Constructs a StringMapper with the given offset.
+     *
+     * @param offset the additional offset (0 based).
+     */
+    public StringMapper(int offset)
+    {
+        this.internalOffset = offset;
+    }
+
+    public String processRow(
+                ResultSet resultSet,
+                int rowOffset)
+            throws TorqueException
+    {
+        try
+        {
+            return resultSet.getString(rowOffset + internalOffset + 1);
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException("Result could not be mapped to a String",
+                    e);
+        }
+    }
+}

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/package.html
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/package.html?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/package.html (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/om/mapper/package.html Wed Oct 27 22:52:15 2010
@@ -0,0 +1,26 @@
+<!--
+ 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.
+-->
+<html>
+  <head>
+  </head>
+  <body>
+    Contains the Mapper interface which defines how to map from
+    a ResultSet to an object, and simple implementations of this interface.
+  </body>
+</html>



---------------------------------------------------------------------
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