db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1231667 [2/4] - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/criteria/ torque-runtime/src/main/java/org/apache/torque/sql/ torque-runtime/src/main/java/org/apache/torque/util/ torque-templates/src/main/resour...
Date Sun, 15 Jan 2012 14:00:19 GMT
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java Sun Jan 15 14:00:18 2012
@@ -100,6 +100,9 @@ public class BasePeerImpl implements Ser
      * @param tableName Name of table.
      * @param columnNames A String[].
      * @return A String[].
+     *
+     * @deprecated This method is not used any more and will be removed in a
+     *             future version of Torque.
      */
     public String[] initCriteriaKeys(
         String tableName,
@@ -133,11 +136,11 @@ public class BasePeerImpl implements Ser
      *             This method will be removed in a future version of Torque.
      */
     public int deleteAll(
-        Connection con,
-        String table,
-        String column,
-        int value)
-        throws TorqueException
+                Connection con,
+                String table,
+                String column,
+                int value)
+            throws TorqueException
     {
         Statement statement = null;
         try
@@ -210,8 +213,7 @@ public class BasePeerImpl implements Ser
     }
 
     /**
-     * Method to perform deletes based on values and keys in a
-     * Criteria.
+     * Method to perform deletes based on conditions in a Criteria.
      *
      * @param criteria The criteria to use.
      *
@@ -221,28 +223,127 @@ public class BasePeerImpl implements Ser
      *         rethrown wrapped into a TorqueException.
      *
      * @deprecated This method causes unexpected results when joins are used.
-     *              Please use doDelete(Criteria, String).
+     *             Please use doDelete(
+     *                 org.apache.torque.criteria.Criteria, TableMap).
+     *             This method will be removed in a future version of Torque.
      */
     protected int doDelete(Criteria criteria) throws TorqueException
     {
-        return doDelete(criteria, (String) null);
+        return doDelete(criteria, (TableMap) null);
+    }
+
+    /**
+     * Method to perform deletes based on conditions in a Criteria.
+     *
+     * @param criteria The criteria to use.
+     *
+     * @return the number of deleted rows.
+     *
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
+     *
+     * @deprecated This method causes unexpected results when joins are used.
+     *             Please use doDelete(
+     *                 org.apache.torque.criteria.Criteria, TableMap).
+     *             This method will be removed in a future version of Torque.
+     */
+    protected int doDelete(org.apache.torque.criteria.Criteria criteria)
+            throws TorqueException
+    {
+        return doDelete(criteria, (TableMap) null);
+    }
+
+    /**
+     * Method to perform deletes based on conditions a Criteria.
+     *
+     * @param criteria The criteria to use.
+     * @param con the Connection to be used for deleting.
+     *
+     * @return the number of deleted rows.
+     *
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
+     *
+     * @deprecated This method causes unexpected results when joins are used.
+     *             Please use doDelete(
+     *                 org.apache.torque.criteria.Criteria, TableMap, Connection).
+     *             This method will be removed in a future version of Torque.
+     */
+    protected int doDelete(Criteria criteria, Connection con)
+        throws TorqueException
+    {
+        if (criteria.values().isEmpty())
+        {
+            throw new TorqueException("No conditions found in Criteria");
+        }
+        Criteria.Criterion criterion
+                = criteria.values().iterator().next();
+        TableMap tableMap = MapHelper.getTableMap(
+                criterion.getColumn(), criteria, null);
+        if (tableMap == null)
+        {
+            throw new TorqueException("Unqualified column name in criteria"
+                    + " or table name not found in database map");
+        }
+        return doDelete(criteria, tableMap, con);
+    }
+
+    /**
+     * Method to perform deletes based on conditions a Criteria.
+     *
+     * @param criteria The criteria to use.
+     * @param con the Connection to be used for deleting.
+     *
+     * @return the number of deleted rows.
+     *
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
+     *
+     * @deprecated This method causes unexpected results when joins are used.
+     *             Please use doDelete(
+     *                 org.apache.torque.criteria.Criteria, TableMap, Connection).
+     *             This method will be removed in a future version of Torque.
+     */
+    protected int doDelete(
+            org.apache.torque.criteria.Criteria criteria,
+            Connection con)
+        throws TorqueException
+    {
+        org.apache.torque.criteria.Criterion criterion
+                = criteria.getTopLevelCriterion();
+        if (criterion == null)
+        {
+            throw new TorqueException("No conditions found in Criteria");
+        }
+        TableMap tableMap = MapHelper.getTableMap(
+                criterion.getColumn(), criteria, null);
+        if (tableMap == null)
+        {
+            throw new TorqueException("Unqualified column name in criteria"
+                    + " or table name not found in database map");
+        }
+        return doDelete(criteria, tableMap, con);
     }
 
     /**
-     * Method to perform deletes based on values and keys in a
-     * Criteria.
+     * Method to perform deletes based on conditions in a Criteria.
      *
      * @param criteria The criteria to use.
-     * @param tableName the name of the table to delete records from.
-     *         If set to null, the name of the table(s) can be extracted from
-     *         the criteria, but this can cause unexpected results.
+     * @param tableMap the table to delete records from.
+     *        If set to null, the name of the table(s) can be extracted from
+     *        the criteria, but this can cause unexpected results
+     *        when joins are used.
      *
      * @return the number of deleted rows.
      *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
+     *
+     * @deprecated Please use doDelete(
+     *                 org.apache.torque.criteria.Criteria, String).
+     *             This method will be removed in a future version of Torque.
      */
-    public int doDelete(Criteria criteria, String tableName)
+    public int doDelete(Criteria criteria, TableMap tableMap)
             throws TorqueException
     {
         Connection con = null;
@@ -251,7 +352,7 @@ public class BasePeerImpl implements Ser
             con = Transaction.beginOptional(
                     criteria.getDbName(),
                     criteria.isUseTransaction());
-            int result = doDelete(criteria, tableName, con);
+            int result = doDelete(criteria, tableMap, con);
             Transaction.commit(con);
             con = null;
             return result;
@@ -266,56 +367,184 @@ public class BasePeerImpl implements Ser
     }
 
     /**
-     * Method to perform deletes based on values and keys in a Criteria.
+     * Method to perform deletes based on conditions in a Criteria.
      *
      * @param criteria The criteria to use.
-     * @param con the Connection to be used for deleting.
+     * @param tableMap the table to delete records from.
+     *        If set to null, the name of the table(s) can be extracted from
+     *        the criteria, but this can cause unexpected results
+     *        when joins are used.
      *
      * @return the number of deleted rows.
      *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
-     * @deprecated This method causes unexpected results when joins are used.
-     *              Please use doDelete(Criteria, String, Connection).
      */
-    protected int doDelete(Criteria criteria, Connection con)
-        throws TorqueException
+    public int doDelete(
+                org.apache.torque.criteria.Criteria criteria,
+                TableMap tableMap)
+            throws TorqueException
     {
-        Criteria.Criterion criterion
-                = criteria.values().iterator().next();
-        String tableName = criterion.getColumn().getTableName();
-        if (tableName == null)
+        Connection con = null;
+        try
+        {
+            con = Transaction.beginOptional(
+                    criteria.getDbName(),
+                    criteria.isUseTransaction());
+            int result = doDelete(criteria, tableMap, con);
+            Transaction.commit(con);
+            con = null;
+            return result;
+        }
+        finally
         {
-            throw new TorqueException("Unqualified column name in criteria");
+            if (con != null)
+            {
+                Transaction.safeRollback(con);
+            }
         }
-        return doDelete(criteria, tableName, con);
     }
 
     /**
-     * Method to perform deletes based on values and keys in a Criteria.
+     * Method to perform deletes based on conditions in a Criteria.
      *
      * @param criteria The criteria to select the records to be deleted,
      *        not null.
-     * @param tableName the name of the table to delete records from, not null.
+     * @param tableMap the table to delete records from.
+     *        If set to null, the name of the table(s) can be extracted from
+     *        the criteria, but this can cause unexpected results
+     *        when joins are used.
      * @param con The database connection for deletion, not null.
      *
      * @return the number of deleted rows.
      *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
+     *
+     * @deprecated Please use doDelete(
+     *                 org.apache.torque.criteria.Criteria, String, Connection).
+     *             This method will be removed in a future version of Torque.
      */
     public int doDelete(
                 Criteria criteria,
-                String tableName,
+                TableMap tableMap,
                 Connection connection)
             throws TorqueException
     {
         Query query = SqlBuilder.buildQuery(criteria);
         query.setType(Query.Type.DELETE);
 
-        String fullTableName = SqlBuilder.getFullTableName(
-                tableName,
-                criteria.getDbName());
+        String fullTableName = null;
+        if (tableMap != null)
+        {
+            fullTableName = SqlBuilder.getFullTableName(
+                    tableMap.getName(),
+                    criteria.getDbName());
+        }
+        else
+        {
+            Column column = criteria.values().iterator().next().getColumn();
+            fullTableName = SqlBuilder.getFullTableName(
+                    column.getFullTableName(),
+                    criteria.getDbName());
+        }
+
+        boolean ownTableAdded = false;
+        for (Query.FromElement fromElement : query.getFromClause())
+        {
+            // Table names are case insensitive in known databases
+            // so use case-insensitive compare
+            if (fullTableName.equalsIgnoreCase(fromElement.getTableName()))
+            {
+                ownTableAdded = true;
+                break;
+            }
+        }
+        if (!ownTableAdded)
+        {
+            query.getFromClause().add(
+                    new Query.FromElement(fullTableName, null, null));
+        }
+        String sql = query.toString();
+
+        PreparedStatement preparedStatement = null;
+        try
+        {
+            preparedStatement = connection.prepareStatement(sql);
+            setPreparedStatementReplacements(
+                    preparedStatement,
+                    query.getPreparedStatementReplacements(),
+                    0);
+            long startTime = System.currentTimeMillis();
+            log.debug("Executing delete " + sql
+                    + ", parameters = "
+                    + query.getPreparedStatementReplacements());
+
+            int affectedRows = preparedStatement.executeUpdate();
+            long queryEndTime = System.currentTimeMillis();
+            log.trace("delete took " + (queryEndTime - startTime)
+                    + " milliseconds");
+
+            preparedStatement.close();
+            preparedStatement = null;
+            return affectedRows;
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
+        finally
+        {
+            if (preparedStatement != null)
+            {
+                try
+                {
+                    preparedStatement.close();
+                }
+                catch (SQLException e)
+                {
+                    log.warn("error closing prepared statement", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Method to perform deletes based on conditions in a Criteria.
+     *
+     * @param criteria The criteria to select the records to be deleted,
+     *        not null.
+     * @param tableMap the table to delete records from.
+     *        If set to null, the name of the table(s) can be extracted from
+     *        the criteria, but this can cause unexpected results
+     *        when joins are used.
+     * @param con The database connection for deletion, not null.
+     *
+     * @return the number of deleted rows.
+     *
+     * @throws TorqueException Any exceptions caught during processing will be
+     *         rethrown wrapped into a TorqueException.
+     */
+    public int doDelete(
+                org.apache.torque.criteria.Criteria criteria,
+                TableMap tableMap,
+                Connection connection)
+            throws TorqueException
+    {
+        Query query = SqlBuilder.buildQuery(criteria);
+        query.setType(Query.Type.DELETE);
+
+        String fullTableName;
+        if (tableMap == null)
+        {
+            fullTableName = SqlBuilder.guessFullTableFromCriteria(criteria);
+        }
+        else
+        {
+            fullTableName = SqlBuilder.getFullTableName(
+                    tableMap.getName(),
+                    criteria.getDbName());
+        }
         boolean ownTableAdded = false;
         for (Query.FromElement fromElement : query.getFromClause())
         {
@@ -678,6 +907,10 @@ public class BasePeerImpl implements Ser
      * @return The results of the query, not null.
      *
      * @throws TorqueException if querying the database fails.
+     *
+     * @deprecated Please use doSelect(org.apache.torque.criteria.Criteria,
+     *                 RecordMapper, TableMap).
+     *             This method will be removed in a future version of Torque.
      */
     public <T> List<T> doSelect(
                 Criteria criteria,
@@ -714,6 +947,51 @@ public class BasePeerImpl implements Ser
     /**
      * Selects rows from a database an maps them to objects.
      *
+     * @param criteria A Criteria specifying the records to select, not null.
+     * @param mapper The mapper creating the objects from the resultSet,
+     *        not null.
+     * @param defaultTableMap The table map used for the
+     *        unqualified columns in the query, not null.
+     *
+     * @return The results of the query, not null.
+     *
+     * @throws TorqueException if querying the database fails.
+     */
+    public <T> List<T> doSelect(
+                org.apache.torque.criteria.Criteria criteria,
+                RecordMapper<T> mapper,
+                TableMap defaultTableMap)
+            throws TorqueException
+    {
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    criteria.getDbName(),
+                    criteria.isUseTransaction());
+
+            List<T> result = doSelect(
+                    criteria,
+                    mapper,
+                    defaultTableMap,
+                    connection);
+
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
+    }
+
+    /**
+     * Selects rows from a database an maps them to objects.
+     *
      * @param query the sql query to execute, not null.
      * @param mapper The mapper creating the objects from the resultSet,
      *        not null.
@@ -844,267 +1122,326 @@ public class BasePeerImpl implements Ser
         return result;
     }
 
-//    /**
-//     * Helper method which returns the primary key contained
-//     * in the given Criteria object.
-//     *
-//     * @param criteria A Criteria.
-//     * @return ColumnMap if the Criteria object contains a primary
-//     *          key, or null if it doesn't.
-//     * @throws TorqueException Any exceptions caught during processing will be
-//     *         rethrown wrapped into a TorqueException.
-//     */
-//    privateColumnMap getPrimaryKey(Criteria criteria)
-//        throws TorqueException
-//    {
-//        // Assume all the keys are for the same table.
-//        String key = (String) criteria.keys().nextElement();
-//
-//        String table = criteria.getTableName(key);
-//        ColumnMap pk = null;
-//
-//        if (!table.equals(""))
-//        {
-//            DatabaseMap dbMap = Torque.getDatabaseMap(criteria.getDbName());
-//            if (dbMap == null)
-//            {
-//                throw new TorqueException("dbMap is null");
-//            }
-//            if (dbMap.getTable(table) == null)
-//            {
-//                throw new TorqueException("dbMap.getTable() is null");
-//            }
-//
-//            ColumnMap[] columns = dbMap.getTable(table).getColumns();
-//
-//            for (int i = 0; i < columns.length; i++)
-//            {
-//                if (columns[i].isPrimaryKey())
-//                {
-//                    pk = columns[i];
-//                    break;
-//                }
-//            }
-//        }
-//        return pk;
-//    }
-//
-//    /**
-//     * Convenience method used to update rows in the DB.  Checks if a
-//     * <i>single</i> int primary key is specified in the Criteria
-//     * object and uses it to perform the udpate.  If no primary key is
-//     * specified an Exception will be thrown.
-//     * <p>
-//     * Use this method for performing an update of the kind:
-//     * <p>
-//     * "WHERE primary_key_id = an int"
-//     * <p>
-//     * To perform an update with non-primary key fields in the WHERE
-//     * clause use doUpdate(criteria, criteria).
-//     *
-//     * @param updateValues A Criteria object containing values used in
-//     *        set clause.
-//     *
-//     * @return the number of affected rows.
-//     *
-//     * @throws TorqueException Any exceptions caught during processing will be
-//     *         rethrown wrapped into a TorqueException.
-//     */
-//    publicint doUpdate(Criteria updateValues) throws TorqueException
-//    {
-//        Connection connection = null;
-//        try
-//        {
-//            connection = Transaction.beginOptional(
-//                    updateValues.getDbName(),
-//                    updateValues.isUseTransaction());
-//            int result = doUpdate(updateValues, connection);
-//            Transaction.commit(connection);
-//            connection = null;
-//            return result;
-//        }
-//        finally
-//        {
-//            if (connection != null)
-//            {
-//                Transaction.safeRollback(connection);
-//            }
-//        }
-//    }
-//
-//    /**
-//     * Convenience method used to update rows in the DB.  Checks if a
-//     * <i>single</i> int primary key is specified in the Criteria
-//     * object and uses it to perform the udpate.  If no primary key is
-//     * specified an Exception will be thrown.
-//     * <p>
-//     * Use this method for performing an update of the kind:
-//     * <p>
-//     * "WHERE primary_key_id = an int"
-//     * <p>
-//     * To perform an update with non-primary key fields in the WHERE
-//     * clause use doUpdate(criteria, criteria).
-//     *
-//     * @param updateValues A Criteria object containing values used in
-//     * set clause.
-//     * @param con A Connection.
-//     *
-//     * @return the number of affected rows.
-//     *
-//     * @throws TorqueException Any exceptions caught during processing will be
-//     *         rethrown wrapped into a TorqueException.
-//     */
-//    publicint doUpdate(Criteria updateValues, Connection con)
-//        throws TorqueException
-//    {
-//        ColumnMap pk = getPrimaryKey(updateValues);
-//        Criteria selectCriteria = null;
-//
-//        if (pk != null && updateValues.containsKey(pk.getFullyQualifiedName()))
-//        {
-//            selectCriteria = new Criteria(2);
-//            selectCriteria.put(pk.getFullyQualifiedName(),
-//                updateValues.remove(pk.getFullyQualifiedName()));
-//        }
-//        else
-//        {
-//            throw new TorqueException("No PK specified for database update");
-//        }
-//
-//        return doUpdate(selectCriteria, updateValues, con);
-//    }
-//
-//    /**
-//     * Executes an update against the database. The rows to be updated
-//     * are selected using <code>criteria</code> and updated using the values
-//     * in <code>updateValues</code>.
-//     *
-//     * @param criteria selects which rows of which table should be updated.
-//     * @param updateValues which columns(map keys) should be set to which
-//     *        values.
-//     * @param connection the database connection to use, not null.
-//     *
-//     * @return the number of affected rows.
-//     *
-//     * @throws TorqueException if updating fails.
-//     */
-//    publicvoid doUpdate(
-//                Criteria selectCriteria,
-//                Criteria updateValues)
-//            throws TorqueException
-//    {
-//        Connection con = null;
-//        try
-//        {
-//            con = Transaction.beginOptional(
-//                    selectCriteria.getDbName(),
-//                    selectCriteria.isUseTransaction());
-//            doUpdate(selectCriteria, updateValues, con);
-//            Transaction.commit(con);
-//        }
-//        catch (TorqueException e)
-//        {
-//            Transaction.safeRollback(con);
-//            throw e;
-//        }
-//    }
-//
-//    /**
-//     * Executes an update against the database. The rows to be updated
-//     * are selected using <code>criteria</code> and updated using the values
-//     * in <code>updateValues</code>.
-//     *
-//     * @param criteria selects which rows of which table should be updated.
-//     * @param updateValues which columns(map keys) should be set to which
-//     *        values.
-//     * @param connection the database connection to use, not null.
-//     *
-//     * @return the number of affected rows.
-//     *
-//     * @throws TorqueException if updating fails.
-//     */
-//    publicint doUpdate(
-//                Criteria criteria,
-//                Criteria updateValues,
-//                Connection connection)
-//            throws TorqueException
-//    {
-//        Query sql = createQuery(criteria);
-//        sql.setType(Query.Type.UPDATE);
-//
-//        // ignore select columns in criteria
-//        sql.getSelectClause().clear();
-//        List<Object> replacementObjects = new ArrayList<Object>();
-//        for (Object updateValueObject : updateValues.entrySet())
-//        {
-//            Map.Entry<?, ?> updateValue = (Map.Entry<?, ?>) updateValueObject;
-//            String columnName = updateValue.getKey().toString();
-//            if (columnName.lastIndexOf(".") != -1)
-//            {
-//                columnName = columnName.substring(
-//                        columnName.lastIndexOf(".") + 1);
-//            }
-//            sql.getSelectClause().add(columnName);
-//            replacementObjects.add(
-//                    ((Criteria.Criterion) updateValue.getValue()).getValue());
-//        }
-//
-//        PreparedStatement preparedStatement = null;
-//        try
-//        {
-//            preparedStatement = connection.prepareStatement(sql.toString());
-//            int position = 1;
-//            for (Object replacementObject : replacementObjects)
-//            {
-//                preparedStatement.setObject(position, replacementObject);
-//                position++;
-//            }
-//            long startTime = System.currentTimeMillis();
-//            log.debug("Executing update " + sql.toString()
-//                    + " using parameters " + replacementObjects);
-//
-//            int affectedRows = preparedStatement.executeUpdate();
-//            long queryEndTime = System.currentTimeMillis();
-//            log.trace("update took " + (queryEndTime - startTime)
-//                    + " milliseconds");
-//
-//            preparedStatement.close();
-//            preparedStatement = null;
-//            return affectedRows;
-//        }
-//        catch (SQLException e)
-//        {
-//            throw new TorqueException(e);
-//        }
-//        finally
-//        {
-//            if (preparedStatement != null)
-//            {
-//                try
-//                {
-//                    preparedStatement.close();
-//                }
-//                catch (SQLException e)
-//                {
-//                    log.warn("error closing prepared statement", e);
-//                }
-//            }
-//        }
-//    }
-
-
     /**
-     * Convenience method used to update rows in the DB.  Checks if a
-     * <i>single</i> primary key is specified in the Criteria
-     * object and uses it to perform the update.  If no primary key is
-     * specified or the table has multiple primary keys,
-     * an Exception will be thrown.
-     * <p>
-     * Use this method for performing an update of the kind:
-     * <p>
-     * "WHERE primary_key_id = someValue"
-     * <p>
-     * To perform an update on a table with multiple primary keys or
+     * Performs a SQL <code>select</code> using a PreparedStatement.
+     *
+     * @param criteria A Criteria specifying the records to select, not null.
+     * @param mapper The mapper creating the objects from the resultSet,
+     *        not null.
+     * @param defaultTableMap The table map used for the
+     *        unqualified columns in the query, TODO or null ???.
+     * @param connection the database connection for selecting records,
+     *        not null.
+     *
+     * @return The results of the query, not null.
+     *
+     * @throws TorqueException Error performing database query.
+     *
+     * @deprecated Please use doSelect(org.apache.torque.criteria.Criteria,
+     *                 RecordMapper, TableMap).
+     *             This method will be removed in a future version of Torque.
+     */
+    public <T> List<T> doSelect(
+            Criteria criteria,
+            RecordMapper<T> mapper,
+            TableMap defaultTableMap,
+            Connection connection)
+        throws TorqueException
+    {
+        correctBooleans(criteria, defaultTableMap);
+
+        Query query = SqlBuilder.buildQuery(criteria);
+        if (query.getFromClause().isEmpty() && defaultTableMap != null)
+        {
+            String tableName = SqlBuilder.getFullTableName(
+                    defaultTableMap.getName(),
+                    criteria.getDbName());
+            query.getFromClause().add(
+                    new Query.FromElement(tableName, null, null));
+        }
+
+        PreparedStatement statement = null;
+        ResultSet resultSet = null;
+        try
+        {
+            statement = connection.prepareStatement(query.toString());
+
+            setPreparedStatementReplacements(
+                    statement,
+                    query.getPreparedStatementReplacements(),
+                    0);
+
+            long startTime = System.currentTimeMillis();
+            log.debug("Executing query " + query
+                    + ", parameters = "
+                    + query.getPreparedStatementReplacements());
+
+            resultSet = statement.executeQuery();
+            long queryEndTime = System.currentTimeMillis();
+            log.trace("query took " + (queryEndTime - startTime)
+                    + " milliseconds");
+
+            int offset;
+            Database database = Torque.getDatabase(criteria.getDbName());
+            if (database.getAdapter().supportsNativeOffset())
+            {
+                offset = 0; //database takes care of offset
+            }
+            else
+            {
+                offset = criteria.getOffset();
+            }
+
+            int limit;
+            if (database.getAdapter().supportsNativeLimit())
+            {
+                limit = -1; //database takes care of offset
+            }
+            else
+            {
+                if (database.getAdapter().supportsNativeOffset())
+                {
+                    limit = criteria.getLimit();
+                }
+                else
+                {
+                    if (criteria.getLimit() == -1)
+                    {
+                        limit = criteria.getLimit();
+                    }
+                    else
+                    {
+                        limit = offset + criteria.getLimit();
+                    }
+                }
+            }
+
+            List<T> result = new ArrayList<T>();
+            int rowNumber = 0;
+            while (resultSet.next())
+            {
+                if (rowNumber < offset)
+                {
+                    rowNumber++;
+                    continue;
+                }
+                if (limit >= 0 && rowNumber >= limit)
+                {
+                    break;
+                }
+
+                T rowResult = mapper.processRow(resultSet, 0);
+                result.add(rowResult);
+
+                rowNumber++;
+            }
+            long mappingEndTime = System.currentTimeMillis();
+            log.trace("mapping took " + (mappingEndTime - queryEndTime)
+                    + " milliseconds");
+
+            if (criteria.isSingleRecord() && result.size() > 1)
+            {
+                throw new TooManyRowsException(
+                        "Criteria expected single Record and "
+                        + "Multiple Records were selected");
+            }
+            return result;
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
+        finally
+        {
+            if (resultSet != null)
+            {
+                try
+                {
+                    resultSet.close();
+                }
+                catch (SQLException e)
+                {
+                    log.warn("error closing resultSet", e);
+                }
+            }
+            if (statement != null)
+            {
+                try
+                {
+                    statement.close();
+                }
+                catch (SQLException e)
+                {
+                    log.warn("error closing statement", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Performs a SQL <code>select</code> using a PreparedStatement.
+     *
+     * @param criteria A Criteria specifying the records to select, not null.
+     * @param mapper The mapper creating the objects from the resultSet,
+     *        not null.
+     * @param defaultTableMap The table map used for the
+     *        unqualified columns in the query, TODO or null ???.
+     * @param connection the database connection for selecting records,
+     *        not null.
+     *
+     * @return The results of the query, not null.
+     *
+     * @throws TorqueException Error performing database query.
+     */
+    public <T> List<T> doSelect(
+                org.apache.torque.criteria.Criteria criteria,
+                RecordMapper<T> mapper,
+                TableMap defaultTableMap,
+                Connection connection)
+            throws TorqueException
+    {
+        correctBooleans(criteria, defaultTableMap);
+
+        Query query = SqlBuilder.buildQuery(criteria);
+        if (query.getFromClause().isEmpty() && defaultTableMap != null)
+        {
+            String tableName = SqlBuilder.getFullTableName(
+                    defaultTableMap.getName(),
+                    criteria.getDbName());
+            query.getFromClause().add(
+                    new Query.FromElement(tableName, null, null));
+        }
+
+        PreparedStatement statement = null;
+        ResultSet resultSet = null;
+        try
+        {
+            statement = connection.prepareStatement(query.toString());
+
+            List<Object> replacements = setPreparedStatementReplacements(
+                    statement,
+                    query.getPreparedStatementReplacements(),
+                    0);
+
+            long startTime = System.currentTimeMillis();
+            log.debug("Executing query " + query
+                    + ", parameters = "
+                    + replacements);
+
+            resultSet = statement.executeQuery();
+            long queryEndTime = System.currentTimeMillis();
+            log.trace("query took " + (queryEndTime - startTime)
+                    + " milliseconds");
+
+            int offset;
+            Database database = Torque.getDatabase(criteria.getDbName());
+            if (database.getAdapter().supportsNativeOffset())
+            {
+                offset = 0; //database takes care of offset
+            }
+            else
+            {
+                offset = criteria.getOffset();
+            }
+
+            int limit;
+            if (database.getAdapter().supportsNativeLimit())
+            {
+                limit = -1; //database takes care of offset
+            }
+            else
+            {
+                if (database.getAdapter().supportsNativeOffset())
+                {
+                    limit = criteria.getLimit();
+                }
+                else
+                {
+                    if (criteria.getLimit() == -1)
+                    {
+                        limit = criteria.getLimit();
+                    }
+                    else
+                    {
+                        limit = offset + criteria.getLimit();
+                    }
+                }
+            }
+
+            List<T> result = new ArrayList<T>();
+            int rowNumber = 0;
+            while (resultSet.next())
+            {
+                if (rowNumber < offset)
+                {
+                    rowNumber++;
+                    continue;
+                }
+                if (limit >= 0 && rowNumber >= limit)
+                {
+                    break;
+                }
+
+                T rowResult = mapper.processRow(resultSet, 0);
+                result.add(rowResult);
+
+                rowNumber++;
+            }
+            long mappingEndTime = System.currentTimeMillis();
+            log.trace("mapping took " + (mappingEndTime - queryEndTime)
+                    + " milliseconds");
+
+            if (criteria.isSingleRecord() && result.size() > 1)
+            {
+                throw new TooManyRowsException(
+                        "Criteria expected single Record and "
+                        + "Multiple Records were selected");
+            }
+            return result;
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
+        finally
+        {
+            if (resultSet != null)
+            {
+                try
+                {
+                    resultSet.close();
+                }
+                catch (SQLException e)
+                {
+                    log.warn("error closing resultSet", e);
+                }
+            }
+            if (statement != null)
+            {
+                try
+                {
+                    statement.close();
+                }
+                catch (SQLException e)
+                {
+                    log.warn("error closing statement", e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Convenience method used to update rows in the DB.  Checks if a
+     * <i>single</i> primary key is specified in the Criteria
+     * object and uses it to perform the update.  If no primary key is
+     * specified or the table has multiple primary keys,
+     * an Exception will be thrown.
+     * <p>
+     * Use this method for performing an update of the kind:
+     * <p>
+     * "WHERE primary_key_id = someValue"
+     * <p>
+     * To perform an update on a table with multiple primary keys or
      * an update with non-primary key fields in the WHERE
      * clause, use doUpdate(ColumnValues, Criteria).
      *
@@ -1178,12 +1515,12 @@ public class BasePeerImpl implements Ser
     {
         TableMap table = updateValues.getTable();
         ColumnMap pk = table.getPrimaryKey();
-        Criteria selectCriteria = null;
+        org.apache.torque.criteria.Criteria selectCriteria = null;
 
         if (pk != null && updateValues.containsKey(pk.getSqlExpression()))
         {
-            selectCriteria = new Criteria();
-            selectCriteria.add(pk,
+            selectCriteria = new org.apache.torque.criteria.Criteria();
+            selectCriteria.where(pk,
                 updateValues.remove(pk.getSqlExpression()));
         }
         else
@@ -1205,32 +1542,179 @@ public class BasePeerImpl implements Ser
      * @return the number of affected rows.
      *
      * @throws TorqueException if updating fails.
+     *
+     * @deprecated Please use doUpdate(
+     *                 org.apache.torque.criteria.Criteria, ColumnValues).
+     *             This method will be removed in a future version of Torque.
+     */
+    public int doUpdate(
+                Criteria selectCriteria,
+                ColumnValues updateValues)
+            throws TorqueException
+    {
+        String databaseName = updateValues.getDbName();
+        if (databaseName == null)
+        {
+            TableMap table = updateValues.getTable();
+            databaseName = table.getDatabaseMap().getDatabase().getName();
+        }
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.begin(databaseName);
+            int result = doUpdate(selectCriteria, updateValues, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
+    }
+
+    /**
+     * Executes an update against the database. The rows to be updated
+     * are selected using <code>criteria</code> and updated using the values
+     * in <code>updateValues</code>.
+     *
+     * @param criteria selects which rows of which table should be updated.
+     * @param updateValues Which columns to update with which values, not null.
+     *
+     * @return the number of affected rows.
+     *
+     * @throws TorqueException if updating fails.
+     */
+    public int doUpdate(
+                org.apache.torque.criteria.Criteria selectCriteria,
+                ColumnValues updateValues)
+            throws TorqueException
+    {
+        String databaseName = updateValues.getDbName();
+        if (databaseName == null)
+        {
+            TableMap table = updateValues.getTable();
+            databaseName = table.getDatabaseMap().getDatabase().getName();
+        }
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.begin(databaseName);
+            int result = doUpdate(selectCriteria, updateValues, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
+    }
+
+    /**
+     * Executes an update against the database. The rows to be updated
+     * are selected using <code>criteria</code> and updated using the values
+     * in <code>updateValues</code>.
+     *
+     * @param criteria selects which rows of which table should be updated.
+     * @param updateValues Which columns to update with which values, not null.
+     * @param connection the database connection to use, not null.
+     *
+     * @return the number of affected rows.
+     *
+     * @throws TorqueException if updating fails.
+     *
+     * @deprecated Please use doUpdate(org.apache.torque.criteria.Criteria,
+     *                 ColumnValues, Connection).
+     *             This method will be removed in a future version of Torque.
      */
     public int doUpdate(
-                Criteria selectCriteria,
-                ColumnValues updateValues)
+                Criteria criteria,
+                ColumnValues updateValues,
+                Connection connection)
             throws TorqueException
     {
-        String databaseName = updateValues.getDbName();
-        if (databaseName == null)
+        Query query = SqlBuilder.buildQuery(criteria);
+        query.setType(Query.Type.UPDATE);
+
+        query.getFromClause().clear();
+        String fullTableName = SqlBuilder.getFullTableName(
+                updateValues.getTable().getName(),
+                criteria.getDbName());
+        query.getFromClause().add(
+                new Query.FromElement(fullTableName, null, null));
+
+        List<JdbcTypedValue> replacementObjects
+                = new ArrayList<JdbcTypedValue>();
+        for (Map.Entry<Column, JdbcTypedValue> updateValue
+                : updateValues.entrySet())
         {
-            TableMap table = updateValues.getTable();
-            databaseName = table.getDatabaseMap().getDatabase().getName();
+            Column column = updateValue.getKey();
+            query.getSelectClause().add(column.getColumnName());
+            replacementObjects.add(updateValue.getValue());
         }
-        Connection connection = null;
+
+        PreparedStatement preparedStatement = null;
         try
         {
-            connection = Transaction.begin(databaseName);
-            int result = doUpdate(selectCriteria, updateValues, connection);
-            Transaction.commit(connection);
-            connection = null;
-            return result;
+            preparedStatement = connection.prepareStatement(query.toString());
+            int position = 1;
+            for (JdbcTypedValue replacementObject : replacementObjects)
+            {
+                Object value = replacementObject.getValue();
+                if (value != null)
+                {
+                    preparedStatement.setObject(position, value);
+                }
+                else
+                {
+                    preparedStatement.setNull(
+                            position,
+                            replacementObject.getJdbcType());
+                }
+                position++;
+            }
+            setPreparedStatementReplacements(
+                    preparedStatement,
+                    query.getPreparedStatementReplacements(),
+                    position - 1);
+            long startTime = System.currentTimeMillis();
+            log.debug("Executing update " + query.toString()
+                    + " using update parameters " + replacementObjects
+                    + " and query parameters "
+                    + query.getPreparedStatementReplacements());
+
+            int affectedRows = preparedStatement.executeUpdate();
+            long queryEndTime = System.currentTimeMillis();
+            log.trace("update took " + (queryEndTime - startTime)
+                    + " milliseconds");
+
+            preparedStatement.close();
+            preparedStatement = null;
+            return affectedRows;
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
         }
         finally
         {
-            if (connection != null)
+            if (preparedStatement != null)
             {
-                Transaction.safeRollback(connection);
+                try
+                {
+                    preparedStatement.close();
+                }
+                catch (SQLException e)
+                {
+                    log.warn("error closing prepared statement", e);
+                }
             }
         }
     }
@@ -1249,7 +1733,7 @@ public class BasePeerImpl implements Ser
      * @throws TorqueException if updating fails.
      */
     public int doUpdate(
-                Criteria criteria,
+                org.apache.torque.criteria.Criteria criteria,
                 ColumnValues updateValues,
                 Connection connection)
             throws TorqueException
@@ -1419,207 +1903,78 @@ public class BasePeerImpl implements Ser
     }
 
     /**
-     * Performs a SQL <code>select</code> using a PreparedStatement.
+     * Sets the prepared statement replacements into a query, possibly
+     * modifying the type if required by DB Drivers.
      *
-     * @param criteria A Criteria specifying the records to select, not null.
-     * @param mapper The mapper creating the objects from the resultSet,
-     *        not null.
-     * @param defaultTableMap The table map used for the
-     *        unqualified columns in the query, TODO or null ???.
-     * @param connection the database connection for selecting records,
-     *        not null.
+     * @param statement the statement to set the parameters in, not null.
+     * @param replacements the replacements to set, not null.
+     * @param offset the offset on the parameters, 0 for no offset.
      *
-     * @return The results of the query, not null.
-     * @throws TorqueException Error performing database query.
+     * @return the parameters set.
+     *
+     * @throws SQLException if setting the parameter fails.
      */
-    public <T> List<T> doSelect(
-            Criteria criteria,
-            RecordMapper<T> mapper,
-            TableMap defaultTableMap,
-            Connection connection)
-        throws TorqueException
-    {
-        correctBooleans(criteria, defaultTableMap);
-
-        Query query = SqlBuilder.buildQuery(criteria);
-        if (query.getFromClause().isEmpty() && defaultTableMap != null)
-        {
-            String tableName = SqlBuilder.getFullTableName(
-                    defaultTableMap.getName(),
-                    criteria.getDbName());
-            query.getFromClause().add(
-                    new Query.FromElement(tableName, null, null));
-        }
-
-        PreparedStatement statement = null;
-        ResultSet resultSet = null;
-        try
-        {
-            statement = connection.prepareStatement(query.toString());
-
-            setPreparedStatementReplacements(
-                    statement,
-                    query.getPreparedStatementReplacements(),
-                    0);
-
-            long startTime = System.currentTimeMillis();
-            log.debug("Executing query " + query
-                    + ", parameters = "
-                    + query.getPreparedStatementReplacements());
-
-            resultSet = statement.executeQuery();
-            long queryEndTime = System.currentTimeMillis();
-            log.trace("query took " + (queryEndTime - startTime)
-                    + " milliseconds");
-
-            int offset;
-            Database database = Torque.getDatabase(criteria.getDbName());
-            if (database.getAdapter().supportsNativeOffset())
-            {
-                offset = 0; //database takes care of offset
-            }
-            else
-            {
-                offset = criteria.getOffset();
-            }
-
-            int limit;
-            if (database.getAdapter().supportsNativeLimit())
-            {
-                limit = -1; //database takes care of offset
-            }
-            else
-            {
-                if (database.getAdapter().supportsNativeOffset())
-                {
-                    limit = criteria.getLimit();
-                }
-                else
-                {
-                    if (criteria.getLimit() == -1)
-                    {
-                        limit = criteria.getLimit();
-                    }
-                    else
-                    {
-                        limit = offset + criteria.getLimit();
-                    }
-                }
-            }
-
-            List<T> result = new ArrayList<T>();
-            int rowNumber = 0;
-            while (resultSet.next())
-            {
-                if (rowNumber < offset)
-                {
-                    rowNumber++;
-                    continue;
-                }
-                if (limit >= 0 && rowNumber >= limit)
-                {
-                    break;
-                }
-
-                T rowResult = mapper.processRow(resultSet, 0);
-                result.add(rowResult);
-
-                rowNumber++;
-            }
-            long mappingEndTime = System.currentTimeMillis();
-            log.trace("mapping took " + (mappingEndTime - queryEndTime)
-                    + " milliseconds");
-
-            if (criteria.isSingleRecord() && result.size() > 1)
-            {
-                throw new TooManyRowsException(
-                        "Criteria expected single Record and "
-                        + "Multiple Records were selected");
-            }
-            return result;
-        }
-        catch (SQLException e)
-        {
-            throw new TorqueException(e);
-        }
-        finally
-        {
-            if (resultSet != null)
-            {
-                try
-                {
-                    resultSet.close();
-                }
-                catch (SQLException e)
-                {
-                    log.warn("error closing resultSet", e);
-                }
-            }
-            if (statement != null)
-            {
-                try
-                {
-                    statement.close();
-                }
-                catch (SQLException e)
-                {
-                    log.warn("error closing statement", e);
-                }
-            }
-        }
-    }
-
-    private void setPreparedStatementReplacements(
+    private List<Object> setPreparedStatementReplacements(
                 PreparedStatement statement,
                 List<Object> replacements,
                 int offset)
             throws SQLException
     {
+        List<Object> result = new ArrayList<Object>(replacements.size());
         int i = 1 + offset;
         for (Object param : replacements)
         {
             if (param instanceof java.sql.Timestamp)
             {
                 statement.setTimestamp(i, (java.sql.Timestamp) param);
+                result.add(param);
             }
             else if (param instanceof java.sql.Date)
             {
                 statement.setDate(i, (java.sql.Date) param);
+                result.add(param);
             }
             else if (param instanceof java.util.Date)
             {
-                // TODO change to timestamp
-                java.sql.Date sqlDate = new java.sql.Date(
+                java.sql.Timestamp sqlDate = new java.sql.Timestamp(
                         ((java.util.Date) param).getTime());
-                statement.setDate(i, sqlDate);
+                statement.setTimestamp(i, sqlDate);
+                result.add(sqlDate);
             }
             else if (param instanceof NumberKey)
             {
-                statement.setBigDecimal(i,
-                    ((NumberKey) param).getBigDecimal());
+                BigDecimal bigDecimal = ((NumberKey) param).getBigDecimal();
+                statement.setBigDecimal(i, bigDecimal);
+                result.add(bigDecimal);
             }
             else if (param instanceof Integer)
             {
                 statement.setInt(i, ((Integer) param).intValue());
+                result.add(param);
             }
             else if (param instanceof Long)
             {
                 statement.setLong(i, ((Long) param).longValue());
+                result.add(param);
             }
             else if (param instanceof BigDecimal)
             {
                 statement.setBigDecimal(i, (BigDecimal) param);
+                result.add(param);
             }
             else if (param instanceof Boolean)
             {
                 statement.setBoolean(i, ((Boolean) param).booleanValue());
+                result.add(param);
             }
             else
             {
                 statement.setString(i, param.toString());
+                result.add(param.toString());
             }
             ++i;
         }
+        return result;
     }
 
 
@@ -1636,6 +1991,10 @@ public class BasePeerImpl implements Ser
      *        not given in a column.
      * @throws TorqueException if the database map for the criteria cannot be
      *         retrieved.
+     *
+     * @deprecated Please use correctBooleans(
+     *                 org.apache.torque.criteria.Criteria, TableMap).
+     *             This method will be removed in a future version of Torque.
      */
     public void correctBooleans(
             Criteria criteria,
@@ -1649,6 +2008,23 @@ public class BasePeerImpl implements Ser
        }
     }
 
+    /**
+     * Checks all columns in the criteria to see whether
+     * booleanchar and booleanint columns are queried with a boolean.
+     * If yes, the query values are mapped onto values the database
+     * does understand, i.e. 0 and 1 for booleanints and N and Y for
+     * booleanchar columns.
+     *
+     * @param criteria The criteria to which teh criterion belongs.
+     * @param criterion The criterion to be checked for booleanint
+     *        and booleanchar columns.
+     * @param defaultTableMap the table map to be used if the table name is
+     *        not given in a column.
+     * @throws TorqueException if the database map for the criteria cannot be
+     *         retrieved.
+     *
+     * @deprecated
+     */
     private void correctBooleans(
                 Criteria criteria,
                 Criteria.Criterion criterion,
@@ -1767,6 +2143,8 @@ public class BasePeerImpl implements Ser
      * @param criterion the criterion to replace Boolean values in.
      * @param trueValue the value by which Boolean.TRUE should be replaced.
      * @param falseValue the value by which Boolean.FALSE should be replaced.
+     *
+     * @deprecated
      */
     private void replaceBooleanValues(
             Criteria.Criterion criterion,

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java Sun Jan 15 14:00:18 2012
@@ -35,6 +35,7 @@ import org.apache.torque.Column;
 import org.apache.torque.ColumnImpl;
 import org.apache.torque.TorqueException;
 import org.apache.torque.criteria.SqlEnum;
+import org.apache.torque.map.TableMap;
 import org.apache.torque.om.mapper.IntegerMapper;
 
 /**
@@ -53,10 +54,32 @@ public class CountHelper
      * @param c Criteria to get the count for.
      * @return number of rows matching the query provided
      * @throws TorqueException if the query could not be executed
+     *
+     * @deprecated use org.apache.toraue.criteria.Criteria instead of
+     *             org.apache.toraue.util.Criteria. This method will be removed
+     *             in Torque 4.1.
      */
     public int count(Criteria c) throws TorqueException
     {
-        return count(c, null, "*");
+        return count(c, null, "*", null);
+    }
+
+    /**
+     * The COUNT function returns the number of rows in a query.
+     * Does not use a connection, hardcode the column to "*" and
+     * set the distinct qualifier to false.
+     * Only use this function if you have added additional constraints to
+     * the criteria, otherwise Torque does not know which table it should
+     * count the datasets in.
+     *
+     * @param c Criteria to get the count for.
+     * @return number of rows matching the query provided
+     * @throws TorqueException if the query could not be executed
+     */
+    public int count(org.apache.torque.criteria.Criteria c)
+            throws TorqueException
+    {
+        return count(c, null, "*", null);
     }
 
     /**
@@ -70,10 +93,32 @@ public class CountHelper
      * @param conn Connection to use
      * @return number of rows matching the query provided
      * @throws TorqueException if the query could not be executed
+     *
+     * @deprecated use org.apache.toraue.criteria.Criteria instead of
+     *             org.apache.toraue.util.Criteria. This method will be removed
+     *             in Torque 4.1.
      */
     public int count(Criteria c, Connection conn) throws TorqueException
     {
-        return count(c, conn, "*");
+        return count(c, conn, "*", null);
+    }
+
+    /**
+     * The COUNT function returns the number of rows in a query.
+     * Hard code the distinct parameter to false and set the column to "*".
+     * Only use this function if you have added additional constraints to
+     * the criteria, otherwise Torque does not know which table it should
+     * count the datasets in.
+     *
+     * @param c Criteria to get the count for.
+     * @param conn Connection to use
+     * @return number of rows matching the query provided
+     * @throws TorqueException if the query could not be executed
+     */
+    public int count(org.apache.torque.criteria.Criteria c, Connection conn)
+            throws TorqueException
+    {
+        return count(c, conn, "*", null);
     }
 
     /**
@@ -84,11 +129,30 @@ public class CountHelper
      *        use the primary key here.
      * @return number of rows matching the query provided
      * @throws TorqueException if the query could not be executed
+     *
+     * @deprecated use org.apache.toraue.criteria.Criteria instead of
+     *             org.apache.toraue.util.Criteria. This method will be removed
+     *             in Torque 4.1.
      */
     public int count(Criteria c, String columnName)
         throws TorqueException
     {
-        return count(c, null, columnName);
+        return count(c, null, columnName, null);
+    }
+
+    /**
+     * Returns the number of rows in a query.
+     *
+     * @param c Criteria to get the count for.
+     * @param columnName Name of database Column which is counted. Preferably,
+     *        use the primary key here.
+     * @return number of rows matching the query provided
+     * @throws TorqueException if the query could not be executed
+     */
+    public int count(org.apache.torque.criteria.Criteria c, String columnName)
+        throws TorqueException
+    {
+        return count(c, null, columnName, null);
     }
 
     /**
@@ -99,10 +163,29 @@ public class CountHelper
      *        use the primary key here.
      * @return number of rows matching the query provided
      * @throws TorqueException if the query could not be executed
+     *
+     * @deprecated use org.apache.toraue.criteria.Criteria instead of
+     *             org.apache.toraue.util.Criteria. This method will be removed
+     *             in Torque 4.1.
      */
     public int count(Criteria c, Column column)
         throws TorqueException
     {
+        return count(c, null, column.getSqlExpression(), null);
+    }
+
+    /**
+     * Returns the number of rows in a query.
+     *
+     * @param c Criteria to get the count for.
+     * @param column the database Column which is counted. Preferably,
+     *        use the primary key here.
+     * @return number of rows matching the query provided
+     * @throws TorqueException if the query could not be executed
+     */
+    public int count(org.apache.torque.criteria.Criteria c, Column column)
+        throws TorqueException
+    {
         return count(c, column.getSqlExpression());
     }
 
@@ -111,14 +194,104 @@ public class CountHelper
      *
      * @param c Criteria to get the count for.
      * @param conn Connection to use
-     * @param columnName Name of database Column which is counted. Preferably,
+     * @param column The database Column which is counted. Preferably,
+     *        use the primary key here.
+     * @return number of rows matching the query provided
+     * @throws TorqueException if the query could not be executed
+     *
+     * @deprecated use org.apache.toraue.criteria.Criteria instead of
+     *             org.apache.toraue.util.Criteria. This method will be removed
+     *             in Torque 4.1.
+     */
+    public int count(Criteria c, Connection conn, Column column)
+        throws TorqueException
+    {
+        return count(c, conn, column.getSqlExpression(), null);
+    }
+
+    /**
+     * Returns the number of rows in a query.
+     *
+     * @param c Criteria to get the count for.
+     * @param conn Connection to use
+     * @param column The database Column which is counted. Preferably,
      *        use the primary key here.
      * @return number of rows matching the query provided
      * @throws TorqueException if the query could not be executed
      */
-    public int count(Criteria c, Connection conn, String columnName)
+    public int count(
+            org.apache.torque.criteria.Criteria c,
+            Connection conn,
+            Column column)
         throws TorqueException
     {
+        return count(c, conn, column.getSqlExpression(), null);
+    }
+
+    /**
+     * Counts all rows in a table.
+     *
+     * @param tableMap the table map of the table to count rows in.
+     *
+     * @return the number of rows in the table.
+     *
+     * @throws TorqueException if the query could not be executed
+     */
+    public int count(TableMap tableMap)
+        throws TorqueException
+    {
+        return count(
+                new org.apache.torque.criteria.Criteria(),
+                null,
+                "*",
+                tableMap);
+    }
+
+    /**
+     * Counts all rows in a table.
+     *
+     * @param tableMap the table map of the table to count rows in.
+     * @param conn the connection to use.
+     *
+     * @return the number of rows in the table.
+     *
+     * @throws TorqueException if the query could not be executed
+     */
+    public int count(TableMap tableMap, Connection conn)
+            throws TorqueException
+    {
+        return count(
+                new org.apache.torque.criteria.Criteria(),
+                conn,
+                "*",
+                tableMap);
+    }
+
+    /**
+     * Returns the number of rows in a query.
+     *
+     * @param c Criteria to get the count for.
+     * @param conn Connection to use
+     * @param columnName Name of database Column which is counted. Preferably,
+     *        use the primary key here.
+     * @param tableMap the table to count the columns in, or null to determine
+     *        the table automatically from the criteria.
+     *
+     * @return number of rows matching the query provided.
+     *
+     * @throws TorqueException if the query could not be executed.
+     *
+     * @deprecated use org.apache.toraue.criteria.Criteria instead of
+     *             org.apache.toraue.util.Criteria. This method will be removed
+     *             in Torque 4.1.
+     */
+    public int count(
+                Criteria c,
+                Connection conn,
+                String columnName,
+                TableMap tableMap)
+            throws TorqueException
+    {
         /* Clear the select columns. */
         c.getSelectColumns().clear();
         c.getOrderByColumns().clear();
@@ -161,14 +334,56 @@ public class CountHelper
      *
      * @param c Criteria to get the count for.
      * @param conn Connection to use
-     * @param column The database Column which is counted. Preferably,
+     * @param columnName Name of database Column which is counted. Preferably,
      *        use the primary key here.
-     * @return number of rows matching the query provided
-     * @throws TorqueException if the query could not be executed
+     * @param tableMap the table to count the columns in, or null to determine
+     *        the table automatically from the criteria.
+     *
+     * @return number of rows matching the query provided.
+     *
+     * @throws TorqueException if the query could not be executed.
      */
-    public int count(Criteria c, Connection conn, Column column)
-        throws TorqueException
+    public int count(
+                org.apache.torque.criteria.Criteria c,
+                Connection conn,
+                String columnName,
+                TableMap tableMap)
+            throws TorqueException
     {
-        return count(c, conn, column.getSqlExpression());
+        /* Clear the select columns. */
+        c.getSelectColumns().clear();
+        c.getOrderByColumns().clear();
+        c.getGroupByColumns().clear();
+
+        UniqueList<String> criteriaSelectModifiers
+            = c.getSelectModifiers();
+
+        boolean distinct = false;
+        if (criteriaSelectModifiers != null
+            && criteriaSelectModifiers.size() > 0
+            && criteriaSelectModifiers.contains(SqlEnum.DISTINCT.toString()))
+        {
+            criteriaSelectModifiers.remove(SqlEnum.DISTINCT.toString());
+            distinct = true;
+        }
+
+        StringBuffer countStr = new StringBuffer("COUNT(");
+        countStr.append(distinct ? SqlEnum.DISTINCT.toString() : "");
+        countStr.append(columnName);
+        countStr.append(")");
+
+        c.addSelectColumn(new ColumnImpl(countStr.toString()));
+
+        List<Integer> result;
+        if (conn == null)
+        {
+            result = BasePeer.doSelect(c, new IntegerMapper(), tableMap);
+        }
+        else
+        {
+            result = BasePeer.doSelect(c, new IntegerMapper(), tableMap, conn);
+        }
+
+        return result.get(0);
     }
 }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java Sun Jan 15 14:00:18 2012
@@ -66,7 +66,7 @@ import org.apache.torque.sql.SqlBuilder;
  *             Use org.apache.torque.criteria.Criteria instead; note that
  *             that class has another semantics of the add.. and or.. methods.
  */
-public class Criteria implements Serializable, CriteriaInterface
+public class Criteria implements Serializable, CriteriaInterface<Criteria>
 {
     /** Serial version. */
     private static final long serialVersionUID = -9001666575933085601L;

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java Sun Jan 15 14:00:18 2012
@@ -35,6 +35,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
+import org.apache.torque.criteria.CriteriaInterface;
 import org.apache.torque.om.mapper.RecordMapper;
 import org.apache.torque.sql.SqlBuilder;
 
@@ -185,7 +186,7 @@ public class LargeSelect<T> implements R
     private int totalRecords = 0;
 
     /** The criteria used for the query. */
-    private Criteria criteria = null;
+    private CriteriaInterface<?> criteria = null;
     /** The last page of results that were returned. */
     private transient List<T> lastResults;
 
@@ -267,7 +268,7 @@ public class LargeSelect<T> implements R
      * </code> in the class named <code>returnBuilderClassName</code>.
      */
     public LargeSelect(
-            Criteria criteria,
+            CriteriaInterface<?> criteria,
             int pageSize,
             String returnBuilderClassName,
             RecordMapper<T> recordMapper)
@@ -308,7 +309,7 @@ public class LargeSelect<T> implements R
      * in the class named <code>returnBuilderClassName</code>.
      */
     public LargeSelect(
-            Criteria criteria,
+            CriteriaInterface<?> criteria,
             int pageSize,
             int memoryPageLimit,
             String returnBuilderClassName,
@@ -322,7 +323,7 @@ public class LargeSelect<T> implements R
             // Add the select columns if necessary.
             if (criteria.getSelectColumns().size() == 0)
             {
-                Class<?>[] argTypes = {Criteria.class};
+                Class<?>[] argTypes = {criteria.getClass()};
                 Method selectColumnAdder =
                     returnBuilderClass.getMethod("addSelectColumns", argTypes);
                 Object[] theArgs = {criteria};
@@ -354,7 +355,10 @@ public class LargeSelect<T> implements R
      * both of offset and limit and if <code>pageSize</code> or
      * <code>memoryLimitPages</code> are less than 1;
      */
-    private void init(Criteria criteria, int pageSize, int memoryLimitPages)
+    private void init(
+            CriteriaInterface<?> criteria,
+            int pageSize,
+            int memoryLimitPages)
     {
         if (criteria.getOffset() != 0 || criteria.getLimit() != -1)
         {
@@ -630,9 +634,21 @@ public class LargeSelect<T> implements R
              * no default peer class inside LargeSelect. This means that all
              * columns not fully qualified will not be modified.
              */
-            BasePeer.correctBooleans(criteria, null);
-
-            String query = SqlBuilder.buildQuery(criteria).toString();
+            String query;
+            if (criteria instanceof Criteria)
+            {
+                BasePeer.correctBooleans((Criteria) criteria, null);
+                query = SqlBuilder.buildQuery((Criteria) criteria).toString();
+            }
+            else
+            {
+                BasePeer.correctBooleans(
+                        (org.apache.torque.criteria.Criteria) criteria,
+                        null);
+                query = SqlBuilder.buildQuery(
+                        (org.apache.torque.criteria.Criteria) criteria)
+                    .toString();
+            }
 
             // Get a connection to the db.
             conn = Torque.getConnection(dbName);
@@ -659,8 +675,23 @@ public class LargeSelect<T> implements R
                     log.debug("run(): Invoking BasePeer.doSelect()");
                 }
 
-                List<T> tempResults
-                        = BasePeer.doSelect(criteria, mapper, null, conn);
+                List<T> tempResults;
+                if (criteria instanceof Criteria)
+                {
+                    tempResults = BasePeer.doSelect(
+                            (Criteria) criteria,
+                            mapper,
+                            null,
+                            conn);
+                }
+                else
+                {
+                    tempResults = BasePeer.doSelect(
+                            (org.apache.torque.criteria.Criteria) criteria,
+                            mapper,
+                            null,
+                            conn);
+                }
                 if (tempResults.size() < criteria.getLimit())
                 {
                     allRecordsRetrieved = true;

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java Sun Jan 15 14:00:18 2012
@@ -104,11 +104,22 @@ public class SummaryHelper
     private boolean excludeExprColumns = false;
 
     /**
-     * Simple constructor
+     * Return a list of ListOrderedMapCI objects with the results of the summary
+     * query.  The ListOrderedMapCI objects have a key of the column name or
+     * function alias and are in the order generated by the query.
+     * The class of the return values are decided by the database driver,
+     * which makes this method not database independent.
+     *
+     * @param crit The base criteria to build on.
+     *
+     * @return Results as a OrderMap<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
      */
-    public SummaryHelper()
+    public List<ListOrderedMapCI> summarize(Criteria crit)
+            throws TorqueException
     {
-        super();
+        return summarize(crit, (List<Class<?>>) null);
     }
 
     /**
@@ -124,13 +135,14 @@ public class SummaryHelper
      *
      * @throws TorqueException if a database error occurs.
      */
-    public List<ListOrderedMapCI> summarize(Criteria crit)
+    public List<ListOrderedMapCI> summarize(
+                org.apache.torque.criteria.Criteria crit)
             throws TorqueException
     {
         return summarize(crit, (List<Class<?>>) null);
     }
 
-     /**
+    /**
      * Return a list of ListOrderedMapCI objects with the results of the summary
      * query.  The ListOrderedMapCI objects have a key of the column name or
      * function alias and are in the order generated by the query.
@@ -171,6 +183,46 @@ public class SummaryHelper
     }
 
     /**
+     * Return a list of ListOrderedMapCI objects with the results of the summary
+     * query.  The ListOrderedMapCI objects have a key of the column name or
+     * function alias and are in the order generated by the query.
+     *
+     * @param crit The base criteria to build on.
+     * @param resultTypes the classes to which the return values of the query
+     *        should be cast, or null to let the database driver decide.
+     *        See org.apache.torque.om.mapper.ObjectListMapper´for the supported
+     *        classes.
+     *
+     * @return Results as a ListOrderMapCI<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<ListOrderedMapCI> summarize(
+                org.apache.torque.criteria.Criteria crit,
+                List<Class<?>> resultTypes)
+            throws TorqueException
+    {
+        Connection connection = null;
+        try
+        {
+            connection = Transaction.beginOptional(
+                    crit.getDbName(),
+                    crit.isUseTransaction());
+            List<ListOrderedMapCI> result = summarize(crit, resultTypes, connection);
+            Transaction.commit(connection);
+            connection = null;
+            return result;
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                Transaction.safeRollback(connection);
+            }
+        }
+    }
+
+    /**
      * Return a list of 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.
@@ -191,6 +243,28 @@ 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.
+     * @param conn The DB Connection to use.
+     *
+     * @return Results as a OrderMap<String, List<Object>> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<ListOrderedMapCI> summarize(
+                org.apache.torque.criteria.Criteria crit,
+                Connection conn)
+            throws TorqueException
+    {
+        return summarize(crit, null, conn);
+    }
+
+    /**
      * Return a list of ListOrderedMapCI objects with the results of the summary
      * query.  The ListOrderedMapCI objects have a key of the column name or
      * function alias and are in the order generated by the query.
@@ -299,6 +373,114 @@ public class SummaryHelper
     }
 
     /**
+     * Return a list of ListOrderedMapCI objects with the results of the summary
+     * query.  The ListOrderedMapCI objects have a key of the column name or
+     * function alias and are in the order generated by the query.
+     *
+     * @param crit The base criteria to build on.
+     * @param resultTypes the classes to which the return values of the query
+     *        should be cast, or null to let the database driver decide.
+     *        See org.apache.torque.om.mapper.ObjectListMapper´for the supported
+     *        classes.
+     * @param conn The DB Connection to use.
+     *
+     * @return Results as a ListOrderedMapCI<String,Values> object.
+     *
+     * @throws TorqueException if a database error occurs.
+     */
+    public List<ListOrderedMapCI> summarize(
+                org.apache.torque.criteria.Criteria crit,
+                List<Class<?>> resultTypes,
+                Connection conn)
+            throws TorqueException
+    {
+        org.apache.torque.criteria.Criteria c = buildCriteria(crit);
+        String query = SqlBuilder.buildQuery(c).toString();
+        RecordMapper<List<Object>> mapper = new ObjectListMapper(resultTypes);
+
+        Statement statement = null;
+        ResultSet resultSet = null;
+        List<List<Object>> rows = new ArrayList<List<Object>>();
+        try
+        {
+            statement = conn.createStatement();
+            long startTime = System.currentTimeMillis();
+            logger.debug("Executing query " + query);
+
+            resultSet = statement.executeQuery(query.toString());
+            long queryEndTime = System.currentTimeMillis();
+            logger.trace("query took " + (queryEndTime - startTime)
+                    + " milliseconds");
+
+            while (resultSet.next())
+            {
+                List<Object> rowResult = mapper.processRow(resultSet, 0);
+                rows.add(rowResult);
+            }
+            long mappingEndTime = System.currentTimeMillis();
+            logger.trace("mapping took " + (mappingEndTime - queryEndTime)
+                    + " milliseconds");
+        }
+        catch (SQLException e)
+        {
+            throw new TorqueException(e);
+        }
+        finally
+        {
+            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);
+                }
+            }
+        }
+
+        List<ListOrderedMapCI> resultsList = new Vector<ListOrderedMapCI>(rows.size());
+        List<String> columnNames = new ArrayList<String>();
+        for (Column column : c.getSelectColumns())
+        {
+            columnNames.add(column.getColumnName());
+        }
+        columnNames.addAll(c.getAsColumns().keySet());
+        for (List<Object> row : rows)
+        {
+            ListOrderedMapCI recordMap = new ListOrderedMapCI();
+            for (int i = 0; i < row.size(); i++)
+            {
+                Object value = row.get(i);
+                String cName = columnNames.get(i);
+                if (cName == null || cName.equals(""))
+                 {
+                    if (excludeExprColumns())
+                    {
+                        continue;
+                    }
+                    cName = "Expr" + i;
+                }
+                recordMap.put(cName, value);
+            }
+            resultsList.add(recordMap);
+        }
+        return resultsList;
+    }
+
+    /**
      * Builds the criteria to use in summarizing the information.  Note that
      * the criteria passed in will be modified.
      *
@@ -380,6 +562,88 @@ public class SummaryHelper
     }
 
     /**
+     * Builds the criteria to use in summarizing the information.  Note that
+     * the criteria passed in will be modified.
+     *
+     * @param c The base criteria to build the summary criteria from.
+     * @return A criteria to use in summarizing the information.
+     * @throws TorqueException
+     */
+    public org.apache.torque.criteria.Criteria buildCriteria(
+            org.apache.torque.criteria.Criteria c) throws TorqueException
+    {
+        c.getSelectColumns().clear();
+        c.getGroupByColumns().clear();
+
+        UniqueList<String> criteriaSelectModifiers;
+        criteriaSelectModifiers = c.getSelectModifiers();
+
+        if (criteriaSelectModifiers != null
+            && criteriaSelectModifiers.size() > 0
+            && criteriaSelectModifiers.contains(SqlEnum.DISTINCT.toString()))
+        {
+            criteriaSelectModifiers.remove(SqlEnum.DISTINCT.toString());
+        }
+        c.setIgnoreCase(false);
+
+        List<Column> cols = getGroupByColumns();
+        boolean haveFromTable = !cols.isEmpty(); // Group By cols define src table.
+        for (Column col : cols)
+        {
+            c.addGroupByColumn(col);
+            c.addSelectColumn(col);
+        }
+        if (haveFromTable)
+        {
+            logger.debug("From table defined by Group By Cols");
+        }
+
+        // Check if the from table is set via a where clause.
+        if (!haveFromTable && c.getTopLevelCriterion() != null)
+        {
+            haveFromTable = true;
+            logger.debug("From table defined by a where clause");
+        }
+
+        ListOrderedMapCI cMap = getAggregates();
+        OrderedMapIterator iMap = cMap.orderedMapIterator();
+        while (iMap.hasNext())
+        {
+            String key = (String) iMap.next();
+            SQLFunction f = (SQLFunction) iMap.getValue();
+            Column col =  f.getColumn();
+            c.addAsColumn(key, new ColumnImpl(
+                    null,
+                    col.getTableName(),
+                    col.getColumnName(),
+                    f.toSQL()));
+            if (!haveFromTable)    // Last chance. Get it from the func.
+            {
+                {
+                    // Kludgy Where table.col = table.col clause to force
+                    // from table identification.
+                    c.add(col,
+                            (col.getColumnName()
+                                    + "=" + col.getColumnName()),
+                            SqlEnum.CUSTOM);
+                    haveFromTable = true;
+
+                    String table = col.getTableName();
+                    logger.debug("From table, '" + table
+                            + "', defined from aggregate column");
+                }
+            }
+        }
+        if (!haveFromTable)
+        {
+            throw new TorqueException(
+                    "No FROM table defined by the GroupBy set, "
+                    + "criteria.setAlias, or specified function column!");
+        }
+        return c;
+    }
+
+    /**
      * <p>
      * Add a column that will be used to group the aggregate results by.
      * This is a first added / first listed on SQL method.  E.g.,

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties Sun Jan 15 14:00:18 2012
@@ -50,6 +50,16 @@ torque.om.silentDbFetch = true
 # If true, Torque adds methods to get database fields by name/position.
 torque.om.addGetByNameMethods = true
 
+# The Criteria and Criterion classes to use.
+# Set to org.apache.torque.criteria.Criteria 
+# and org.apache.torque.criteria.Criterion for the new Criteria object
+# with the changed semantics.
+# Set to org.apache.torque.util.Criteria 
+# and org.apache.torque.util.Criteria.Criterion for the old Criteria object
+# with the original semantics.
+torque.om.criteriaClass = org.apache.torque.criteria.Criteria
+torque.om.criterionClass = org.apache.torque.criteria.Criterion
+
 # If true, Torque generates a bean object for each data object, 
 # plus methods to convert data objects to beans and vice versa.
 torque.om.generateBeans = false

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm (original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm Sun Jan 15 14:00:18 2012
@@ -53,7 +53,7 @@ import org.apache.torque.om.Persistent;
 #if ($torqueGen.booleanOption("torque.om.addGetByNameMethods"))
 import org.apache.torque.om.ColumnAccessByName;
 #end##
-import org.apache.torque.util.Criteria;
+import $torqueGen.option("torque.om.criteriaClass");
 import org.apache.torque.util.Transaction;
 import org.apache.commons.lang.ObjectUtils;
 



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