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 [3/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
Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/ColumnValues.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/ColumnValues.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/ColumnValues.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/ColumnValues.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,169 @@
+package org.apache.torque.util;
+
+/*
+ * 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.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.torque.map.TableMap;
+
+/*
+ * 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.
+ */
+/**
+ * A class containing values for database columns.
+ *
+ * @version $Id: BasePeer.java 1003834 2010-10-02 16:51:32Z tfischer $
+ */
+public class ColumnValues implements Map<String, JdbcTypedValue>
+{
+    /** The table to which these column values belong to. */
+    private TableMap table;
+
+    /** The column values, keyed by the column names. */
+    private Map<String, JdbcTypedValue> columnValues;
+
+    /**
+     * Constructor.
+     *
+     * @param columnValues the column values, or null.
+     */
+    public ColumnValues(TableMap table)
+    {
+        this.table = table;
+        this.columnValues = new HashMap<String, JdbcTypedValue>();
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param columnValues the column values, or null.
+     * @param table the table to which these values belong to.
+     */
+    public ColumnValues(
+            Map<String, JdbcTypedValue> columnValues,
+            TableMap table)
+    {
+        this.table = table;
+        if (columnValues == null)
+        {
+            this.columnValues = new HashMap<String, JdbcTypedValue>();
+        }
+        else
+        {
+            this.columnValues = columnValues;
+        }
+    }
+
+    /**
+     * Returns the table to which these columns belong to.
+     *
+     * @return the table to which these columns belong to.
+     */
+    public TableMap getTable()
+    {
+        return table;
+    }
+
+    public int size()
+    {
+        return columnValues.size();
+    }
+
+    public boolean isEmpty()
+    {
+        return columnValues.isEmpty();
+    }
+
+    public boolean containsKey(Object key)
+    {
+        return columnValues.containsKey(key);
+    }
+
+    public boolean containsValue(Object value)
+    {
+        return columnValues.containsValue(value);
+    }
+
+    public JdbcTypedValue get(Object key)
+    {
+        return columnValues.get(key);
+    }
+
+    public JdbcTypedValue put(String key, JdbcTypedValue value)
+    {
+        return columnValues.put(key, value);
+    }
+
+    public JdbcTypedValue remove(Object key)
+    {
+        return columnValues.remove(key);
+    }
+
+    public void putAll(Map<? extends String, ? extends JdbcTypedValue> t)
+    {
+        columnValues.putAll(t);
+    }
+
+    public void clear()
+    {
+        columnValues.clear();
+    }
+
+    public Set<String> keySet()
+    {
+        return columnValues.keySet();
+    }
+
+    public Collection<JdbcTypedValue> values()
+    {
+        return columnValues.values();
+    }
+
+    public Set<java.util.Map.Entry<String, JdbcTypedValue>> entrySet()
+    {
+        return columnValues.entrySet();
+    }
+
+    @Override
+    public String toString()
+    {
+        return "ColumnValues [table=" + table 
+            + ", columnValues=" + columnValues + "]";
+    }
+
+}

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java Wed Oct 27 22:52:15 2010
@@ -32,9 +32,7 @@ import java.sql.Connection;
 import java.util.List;
 
 import org.apache.torque.TorqueException;
-
-import com.workingdogs.village.DataSetException;
-import com.workingdogs.village.Record;
+import org.apache.torque.om.mapper.IntegerMapper;
 
 /**
  * Counts entries matching a criteria.
@@ -127,24 +125,16 @@ public class CountHelper
 
         c.addSelectColumn(countStr.toString());
 
-        List<Record> result;
+        List<Integer> result;
         if (conn == null)
         {
-            result = BasePeer.doSelectVillageRecords(c);
+            result = BasePeer.doSelect(c, new IntegerMapper(), null);
         }
         else
         {
-            result = BasePeer.doSelectVillageRecords(c, conn);
+            result = BasePeer.doSelect(c, new IntegerMapper(), null, conn);
         }
 
-        Record record = (Record) result.get(0);
-        try
-        {
-            return record.getValue(1).asInt();
-        }
-        catch (DataSetException e)
-        {
-            throw new TorqueException(e);
-        }
+        return result.get(0);
     }
 }

Added: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/JdbcTypedValue.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/JdbcTypedValue.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/JdbcTypedValue.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/JdbcTypedValue.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,94 @@
+package org.apache.torque.util;
+
+import java.sql.Types;
+
+/*
+ * 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.
+ */
+/**
+ * A value plus its JDBC type.
+ *
+ * @version $Id: BasePeer.java 1003834 2010-10-02 16:51:32Z tfischer $
+ */
+public class JdbcTypedValue
+{
+    /** The JDBC type as in <code>java.sql.Types</code>. **/
+    private int jdbcType;
+
+    /** The value; may be null. */
+    private Object value;
+
+    /**
+     * Constructor.
+     *
+     * @param jdbcType The JDBC type as in <code>java.sql.Types</code>.
+     * @param value The value; may be null.
+     */
+    public JdbcTypedValue(Object value, int jdbcType)
+    {
+        this.jdbcType = jdbcType;
+        this.value = value;
+    }
+
+    /**
+     * Returns the JDBC type as in <code>java.sql.Types</code>.
+     *
+     * @return the JDBC type of the value.
+     */
+    public int getJdbcType()
+    {
+        return jdbcType;
+    }
+
+    /**
+     * Sets the JDBC type as in <code>java.sql.Types</code>.
+     *
+     * @param jdbcType the JDBC type of the value.
+     */
+    public void setJdbcType(int jdbcType)
+    {
+        this.jdbcType = jdbcType;
+    }
+
+    /**
+     * Sets the value.
+     *
+     * @return the value, may be null.
+     */
+    public Object getValue()
+    {
+        return value;
+    }
+
+    /**
+     * Returns the value.
+     *
+     * @return value the value, or null.
+     */
+    public void setValue(Object value)
+    {
+        this.value = value;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "JdbcTypedValue [jdbcType=" + jdbcType
+            + ", value=" + value + "]";
+    }
+}

Modified: db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java Wed Oct 27 22:52:15 2010
@@ -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/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/Query.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/Query.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/Query.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/Query.java Wed Oct 27 22:52:15 2010
@@ -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/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java Wed Oct 27 22:52:15 2010
@@ -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;
@@ -32,12 +36,10 @@ import org.apache.commons.collections.ma
 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
@@ -111,54 +113,184 @@ public class SummaryHelper
      * 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.
-     * @return Results as a OrderMap<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<OrderedMap> summarize(Criteria crit)
-                                throws TorqueException, DataSetException
+            throws TorqueException
     {
-        return summarize(crit, null);
+        return summarize(crit, (List<Class<?>>) null);
+    }
+
+            /**
+     * 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.
+     *
+     * @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 OrderMap<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<OrderedMap> summarize(
+                Criteria crit,
+                List<Class<?>> resultTypes)
+            throws TorqueException
+    {
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    crit.getDbName(),
+                    crit.isUseTransaction());
+            List<OrderedMap> result = summarize(crit, resultTypes, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
     }
 
     /**
      * 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 OrderMap<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<OrderedMap> summarize(Criteria crit, Connection conn)
-                                 throws TorqueException, DataSetException
+            throws TorqueException
+    {
+        return summarize(crit, null, conn);
+    }
+
+    /**
+     * 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.
+     *
+     * @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 OrderMap<String,Values> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<OrderedMap> 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);
 
-        List<Record> results;
-        if (conn == null)
+        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);
+                }
+            }
         }
 
-        Vector<OrderedMap> resultsList = new Vector<OrderedMap>(results.size());
-        for (Record rec : results)
+        List<OrderedMap> resultsList = new Vector<OrderedMap>(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)
         {
             ListOrderedMap recordMap = new ListOrderedMap();
-            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();
+                Object value = row.get(i);
+                String cName = columnNames.get(i);
                 if (cName == null || cName.equals(""))
                  {
                     if (excludeExprColumns())
@@ -351,15 +483,8 @@ public class SummaryHelper
                         heading += ", ";
                     }
                 }
-                Value v = (Value) rI.getValue();
-                if (v.isString())
-                {
-                    recString += "\"" + v.toString() + "\"";
-                }
-                else
-                {
-                    recString += v.toString();
-                }
+                Object v = rI.getValue();
+                recString += v.toString();
                 if (rI.hasNext())
                 {
                     recString += ", ";

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/pom.xml?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/pom.xml (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/pom.xml Wed Oct 27 22:52:15 2010
@@ -77,6 +77,9 @@
       <plugin>
         <artifactId>maven-assembly-plugin</artifactId>
         <configuration>
+          <appendAssemblyId>false</appendAssemblyId>
+          <appendAssemblyId>false</appendAssemblyId>
+          <tarLongFileMode>gnu</tarLongFileMode>
           <descriptors>
             <descriptor>../torque-maven-parent/src/main/assembly/bin-with-dependencies.xml</descriptor>
           </descriptors>

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java Wed Oct 27 22:52:15 2010
@@ -23,7 +23,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SizedForBitDataSqlType;
 import org.apache.torque.templates.typemapping.SqlType;
 

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java Wed Oct 27 22:52:15 2010
@@ -19,7 +19,7 @@ package org.apache.torque.templates.plat
  * under the License.
  */
 
-import org.apache.torque.generator.jdbc.SchemaType;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/SchemaTypeHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/SchemaTypeHelper.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/SchemaTypeHelper.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/SchemaTypeHelper.java Wed Oct 27 22:52:15 2010
@@ -20,13 +20,13 @@ package org.apache.torque.templates.tran
  */
 
 import org.apache.torque.generator.control.ControllerState;
-import org.apache.torque.generator.jdbc.SchemaType;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.transform.SourceTransformerException;
 import org.apache.torque.templates.TemplateOptionName;
 import org.apache.torque.templates.TorqueSchemaAttributeName;
 import org.apache.torque.templates.platform.Platform;
 import org.apache.torque.templates.platform.PlatformFactory;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.SqlType;
 
 /**

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/ColumnAttributeName.java Wed Oct 27 22:52:15 2010
@@ -59,6 +59,11 @@ public enum ColumnAttributeName implemen
     VILLAGE_METHOD("villageMethod"),
 
     /**
+     * The getter to get the column from a result set.
+     */
+    RESULT_SET_GETTER("resultSetGetter"),
+
+    /**
      * An instance of the object for the type map.
      */
     SAMPLE_OBJECT("sampleObject");

Added: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/DatabaseChildElementName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/DatabaseChildElementName.java?rev=1028130&view=auto
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/DatabaseChildElementName.java (added)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/DatabaseChildElementName.java Wed Oct 27 22:52:15 2010
@@ -0,0 +1,65 @@
+package org.apache.torque.templates.transformer.om;
+
+/*
+ * 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 org.apache.torque.generator.source.SourceElementName;
+
+/**
+ * Contains the child elements for a database source element which are not
+ * defined in the Torque schema. These elements might be created
+ * in the transformation of a database.
+ */
+public enum DatabaseChildElementName implements SourceElementName
+{
+    /**
+     * The element containing all known tables including those
+     * loaded from an external schema.
+     */
+    ALL_TABLES("all-tables");
+
+    /** The name of the source element, not null. */
+    private String name;
+
+    /**
+     * Constructor.
+     *
+     * @param name the name of the source element, not null.
+     */
+    private DatabaseChildElementName(String name)
+    {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the referenced source element.
+     *
+     * @return the name of the referenced source element.
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    @Override
+    public String toString()
+    {
+        return name;
+    }
+}

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FindHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FindHelper.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FindHelper.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/FindHelper.java Wed Oct 27 22:52:15 2010
@@ -42,25 +42,29 @@ final class FindHelper
     }
 
     /**
-     * Finds a table in the database by name.
+     * Finds a table in the given root element by name. The root element must
+     * be a database element.
      *
-     * @param database the database Source element, not null.
+     * @param root the database Source element, not null.
      * @param tableName the table name, not null.
+     * @param searchExternalSchemata if the table should also be located
+     *        in the external schemata. 
      *
      * @return the column's source element, or null if no matching table
      *         exists.
      */
     public static SourceElement findTable(
-            SourceElement database,
-            String tableName)
+            SourceElement root,
+            String tableName,
+            boolean searchExternalSchemata)
     {
         if (!TorqueSchemaElementName.DATABASE.getName().equals(
-                database.getName()))
+                root.getName()))
         {
             throw new IllegalArgumentException("Wrong source element "
-                    + database.getName());
+                    + root.getName());
         }
-        for (SourceElement table : database.getChildren(
+        for (SourceElement table : root.getChildren(
                 TorqueSchemaElementName.TABLE))
         {
             if (tableName.equals(table.getAttribute(
@@ -69,6 +73,23 @@ final class FindHelper
                 return table;
             }
         }
+        if (searchExternalSchemata)
+        {
+            for (SourceElement externalSchema : root.getChildren(
+                    TorqueSchemaElementName.EXTERNAL_SCHEMA))
+            {
+                SourceElement databaseElement
+                    = externalSchema.getChild(TorqueSchemaElementName.DATABASE);
+                SourceElement result = findTable(
+                        databaseElement,
+                        tableName,
+                        searchExternalSchemata);
+                if (result != null)
+                {
+                    return result;
+                }
+            }
+        }
         return null;
     }
 

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/LoadExternalSchemaTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/LoadExternalSchemaTransformer.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/LoadExternalSchemaTransformer.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/LoadExternalSchemaTransformer.java Wed Oct 27 22:52:15 2010
@@ -41,7 +41,6 @@ import org.apache.torque.templates.Torqu
  *
  * @version $Id: $
  */
-// TODO: move to parent package org.apache.torque.templates.transformer
 public class LoadExternalSchemaTransformer implements SourceTransformer
 {
     /** The class log. */
@@ -50,9 +49,11 @@ public class LoadExternalSchemaTransform
 
     /**
      * Loads the external schemata tables into the current graph.
-     * The tables are added as if they were  normal tables
-     * but with the attribute fromExternalSchema set to the path
-     * of the external schema from which the table was added.
+     * The external database element is added as child of the
+     * external-schema element.
+     * Also, an all-tables child element is added to the root element,
+     * which is filled with all tables from the external schema plus its own
+     * tables.
      *
      * @param root the database root element of the source tree, not null.
      * @param controllerState the controller state, not null.
@@ -66,6 +67,14 @@ public class LoadExternalSchemaTransform
     {
         List<SourceElement> externalSchemaElementList
                 = root.getChildren(TorqueSchemaElementName.EXTERNAL_SCHEMA);
+        SourceElement allTables = root.getChild(
+                DatabaseChildElementName.ALL_TABLES);
+        if (allTables == null)
+        {
+            allTables = new SourceElement(DatabaseChildElementName.ALL_TABLES);
+            root.getChildren().add(allTables);
+        }
+
         for (SourceElement externalSchemaElement : externalSchemaElementList)
         {
             File currentSourceFile = controllerState.getSourceFile();
@@ -82,19 +91,22 @@ public class LoadExternalSchemaTransform
                         controllerState);
                 SourceElement externalSchemaRootElement
                         = fileSource.getRootElement();
+
                 this.transform(externalSchemaRootElement, controllerState);
-                Iterator<SourceElement> childIt
-                        = externalSchemaRootElement.getChildren().iterator();
-                while (childIt.hasNext())
+
+                externalSchemaElement.getChildren().add(
+                        externalSchemaRootElement);
+
+                SourceElement externalAllTables 
+                        = externalSchemaRootElement.getChild(
+                                DatabaseChildElementName.ALL_TABLES);
+
+                // fill root's all-tables with all external tables
+                for (SourceElement externalTable 
+                        : externalAllTables.getChildren(
+                            TorqueSchemaElementName.TABLE))
                 {
-                    SourceElement child = childIt.next();
-                    root.getChildren().add(child);
-                    child.setAttribute(
-                            TableAttributeName.FROM_EXTERNAL_SCHEMA,
-                            relativePath);
-                    // detach from previous parent so that the
-                    // new parent is the primary parent.
-                    childIt.remove();
+                    allTables.getChildren().add(externalTable);
                 }
             }
             catch (SourceException e)
@@ -105,6 +117,12 @@ public class LoadExternalSchemaTransform
                 throw new SourceTransformerException(e);
             }
         }
+        // add own tablkes to root's all-tables
+        for (SourceElement table 
+                : root.getChildren(TorqueSchemaElementName.TABLE))
+        {
+            allTables.getChildren().add(table);
+        }
         return root;
     }
 }

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMColumnTransformer.java Wed Oct 27 22:52:15 2010
@@ -25,8 +25,8 @@ import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.torque.generator.control.ControllerState;
-import org.apache.torque.generator.jdbc.SchemaType;
 import org.apache.torque.generator.processor.string.Camelbacker;
+import org.apache.torque.generator.processor.string.WrapReservedJavaWords;
 import org.apache.torque.generator.source.SourceElement;
 import org.apache.torque.generator.source.transform.SourceTransformerException;
 import org.apache.torque.templates.TorqueSchemaAttributeName;
@@ -34,8 +34,9 @@ import org.apache.torque.templates.Torqu
 import org.apache.torque.templates.TorqueSchemaJavaType;
 import org.apache.torque.templates.transformer.SchemaTypeHelper;
 import org.apache.torque.templates.typemapping.JavaType;
+import org.apache.torque.templates.typemapping.ResultSetGetter;
+import org.apache.torque.templates.typemapping.SchemaType;
 import org.apache.torque.templates.typemapping.TypeMap;
-import org.apache.torque.templates.typemapping.VillageMethod;
 
 /**
  * Sets the class names and packages for the OM model.
@@ -52,6 +53,10 @@ public class OMColumnTransformer
     /** Names which cannot be used as constants for column names. */
     private static final Set<String> RESERVED_CONSTANT_NAMES;
 
+    /** Prevents reserved java words. */
+    private static WrapReservedJavaWords reservedJavaWordsWrapper
+            = new WrapReservedJavaWords();
+
     static
     {
         Set<String> reservedConstantNames = new HashSet<String>();
@@ -78,6 +83,7 @@ public class OMColumnTransformer
         SchemaType schemaType = SchemaTypeHelper.getSchemaType(
                 columnElement,
                 controllerState);
+        columnElement.setAttribute("schemaType", schemaType);
 
         JavaType fieldJavaType = getFieldJavaType(columnElement, schemaType);
         columnElement.setAttribute(
@@ -95,7 +101,7 @@ public class OMColumnTransformer
         setSetterNameAttribute(columnElement);
         setAccessModifierAttributes(columnElement);
         setDefaultValueAttribute(columnElement, fieldJavaType);
-        setVillageMethodAttribute(columnElement, fieldJavaType, schemaType);
+        setResultSetGetterAttribute(columnElement, schemaType);
         setSampleObjectAttribute(columnElement, schemaType);
 
         for (SourceElement inheritanceElement : columnElement.getChildren(
@@ -313,6 +319,7 @@ public class OMColumnTransformer
         String javaName = (String) columnElement.getAttribute(
                 TorqueSchemaAttributeName.JAVA_NAME);
         String fieldName = StringUtils.uncapitalize(javaName);
+        fieldName = reservedJavaWordsWrapper.process(fieldName);
         columnElement.setAttribute(
                 JavaFieldAttributeName.FIELD_NAME,
                 fieldName);
@@ -600,39 +607,43 @@ public class OMColumnTransformer
     }
 
     /**
-     * Sets the villageMethod attribute of the column element
-     * if it is not already set.
+     * Sets the resultSetGetter attribute of the column element
+     * if it is not already set. 
+     * If the resultSetGetter is a string value, it is converted to
+     * a ResultSetGetter value.
      *
      * @param columnElement the column element, not null.
-     * @param javaType the type of the java field corresponding to the
-     *        column, not null.
      * @param schemaType the schema type of the column, not null.
      */
-    protected void setVillageMethodAttribute(
+    protected void setResultSetGetterAttribute(
             SourceElement columnElement,
-            JavaType javaType,
             SchemaType schemaType)
     {
-        if (columnElement.getAttribute(ColumnAttributeName.VILLAGE_METHOD)
-                != null)
+        ResultSetGetter resultSetGetter = null; 
+        Object originalValue = columnElement.getAttribute(
+                ColumnAttributeName.RESULT_SET_GETTER);
+
+        if (originalValue != null)
         {
-            return;
+            if (originalValue instanceof String)
+            {
+                resultSetGetter = ResultSetGetter.getByMethodName(
+                        (String) originalValue);
+            }
         }
-        VillageMethod villageMethod;
-        if (javaType.isPrimitive())
+        else
         {
-            villageMethod = TypeMap.getVillageMethod(schemaType);
+            resultSetGetter = TypeMap.getResultSetGetter(schemaType);
         }
-        else
+
+        if (resultSetGetter != null)
         {
-            villageMethod = TypeMap.getVillageObjectMethod(schemaType);
+            columnElement.setAttribute(
+                    ColumnAttributeName.RESULT_SET_GETTER,
+                    resultSetGetter);
         }
-        columnElement.setAttribute(
-                ColumnAttributeName.VILLAGE_METHOD,
-                villageMethod);
     }
 
-
     /**
      * Sets the sampleObject attribute of the column element
      * if it is not already set.

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMForeignKeyColumnTransformer.java Wed Oct 27 22:52:15 2010
@@ -78,7 +78,7 @@ import org.apache.torque.templates.Torqu
  *   ...
  *
  * Note that the foreign keys in the foreign-keys and referencing-foreign-keys
- * are
+ * are the original elements, not just copies.
  */
 public class OMForeignKeyColumnTransformer
 {
@@ -129,7 +129,8 @@ public class OMForeignKeyColumnTransform
                                         TorqueSchemaAttributeName.FOREIGN);
                         SourceElement foreignTable = FindHelper.findTable(
                                 database,
-                                foreignTableName);
+                                foreignTableName,
+                                true);
                         if (foreignTable == null)
                         {
                             throw new SourceTransformerException(
@@ -184,7 +185,7 @@ public class OMForeignKeyColumnTransform
                 {
                     Object referenceForeignColumnName
                             = reference.getAttribute(
-                                    TorqueSchemaAttributeName.FOREIGN_TABLE);
+                                    TorqueSchemaAttributeName.FOREIGN);
                     String referenceLocalColumnName
                             = (String) reference.getAttribute(
                                     TorqueSchemaAttributeName.LOCAL);



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