Author: tfischer
Date: Sun Jan 15 14:00:18 2012
New Revision: 1231667
URL: http://svn.apache.org/viewvc?rev=1231667&view=rev
Log:
TORQUE-178
- extend the methods covered by CriteriaInterface
- use both criteria classes in BasePeer, SQLBuilder, CountHelper and
SummaryHelper
- make configurable which Criteria class to use in the templates. Default is
the new class.
- adjusted the test project to use the new class.
Also externalized Date tests in test project
Added:
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DateTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/BasePeerTest.java
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/CriteriaInterface.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/CountHelper.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/Criteria.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/baseDbObject.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/dbObject/base/getterReferencingObject.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/imports.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/buildCriteria.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doDelete.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/doUpdate.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencedObject.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/fillReferencingObjects.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/imports.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/impl/base/retrieveByPK.vm
db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/BeanTestConditional.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DataTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/DocsTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ForeignKeySchemaData.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/InitShutdownTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/JndiConfigurationTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/PkSchemaData.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/DeleteTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/generated/peer/FillerTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/sql/DatabaseTools.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java
db/torque/torque4/trunk/torque-test/src/test/profile/oracle/Torque.properties
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
Sun Jan 15 14:00:18 2012
@@ -54,7 +54,7 @@ import org.apache.torque.util.UniqueList
* @author <a href="mailto:[email protected]">Thomas Vandahl</a>
* @version $Id: Criteria.java 1211142 2011-12-06 21:04:03Z tfischer $
*/
-public class Criteria implements Serializable, CriteriaInterface
+public class Criteria implements Serializable, CriteriaInterface<Criteria>
{
/** Serial version. */
private static final long serialVersionUID = -9001666575933085601L;
@@ -308,7 +308,7 @@ public class Criteria implements Seriali
*
* @return a <code>boolean</code> value
*/
- protected boolean isUseTransaction()
+ public boolean isUseTransaction()
{
return useTransaction;
}
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/CriteriaInterface.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/CriteriaInterface.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/CriteriaInterface.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/CriteriaInterface.java
Sun Jan 15 14:00:18 2012
@@ -37,7 +37,7 @@ import org.apache.torque.util.UniqueList
* @deprecated This interface will only exist temporarily and will be removed
* as soon as the class org.apache.torque.util.Criteria is removed.
*/
-public interface CriteriaInterface
+public interface CriteriaInterface<T>
{
/**
* Get the column aliases.
@@ -169,4 +169,22 @@ public interface CriteriaInterface
* @return An UniqueList with the name of the groupBy clause, not null.
*/
UniqueColumnList getGroupByColumns();
+
+ /**
+ * Set a limit for the query
+ *
+ * @param limit The upper limit for the number of records returned
+ * by a query.
+ * @return A modified Criteria object.
+ */
+ public T setLimit(int limit);
+
+ /**
+ * Set the offset.
+ *
+ * @param offset how many records should be skipped at the start of the
+ * result.
+ * @return A modified Criteria object.
+ */
+ public T setOffset(int offset);
}
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/sql/SqlBuilder.java
Sun Jan 15 14:00:18 2012
@@ -150,7 +150,7 @@ public final class SqlBuilder
* @throws TorqueException if the select columns can not be processed.
*/
private static void processSelectColumns(
- final CriteriaInterface criteria,
+ final CriteriaInterface<?> criteria,
final Query query,
final Database database)
throws TorqueException
@@ -550,7 +550,7 @@ public final class SqlBuilder
* @throws TorqueException if the GroupBy-Columns can not be processed
*/
private static void processGroupBy(
- final CriteriaInterface criteria,
+ final CriteriaInterface<?> criteria,
final Database database,
final Query query)
throws TorqueException
@@ -721,6 +721,104 @@ public final class SqlBuilder
}
/**
+ * Unqualify a table or column name.
+ *
+ * @param name the name to unqualify.
+ * If null is passed in, null is returned.
+ *
+ * @return The unqualified name.
+ */
+ public static String getUnqualifiedName(
+ final String name,
+ final String dbName)
+ throws TorqueException
+ {
+ if (name == null)
+ {
+ return null;
+ }
+
+ int dotIndex = name.lastIndexOf(".");
+ if (dotIndex == -1)
+ {
+ return name;
+ }
+
+ return name.substring(dotIndex + 1);
+ }
+
+ /**
+ * Guesses a table name from a criteria by inspecting the first
+ * column in the criteria.
+ *
+ * @param criteria the criteria to guess the table name from.
+ *
+ * @return the table name, not null.
+ *
+ * @throws TorqueException if the table name cannot be determined.
+ */
+ public static String guessFullTableFromCriteria(Criteria criteria)
+ throws TorqueException
+ {
+ org.apache.torque.criteria.Criterion criterion
+ = criteria.getTopLevelCriterion();
+ if (criterion == null)
+ {
+ throw new TorqueException("Could not determine table name "
+ + " as criteria contains no criterion");
+ }
+ while (criterion.isComposite())
+ {
+ criterion = criterion.getParts().iterator().next();
+ }
+ Column column = criterion.getColumn();
+ String tableName = column.getFullTableName();
+ if (tableName == null)
+ {
+ throw new TorqueException("Could not determine table name "
+ + " as first criterion contains no table name");
+ }
+ return tableName;
+ }
+
+ /**
+ * Returns the table map for a table.
+ *
+ * @param tableName the name of the table.
+ * @param dbName the name of the database, null for the default db.
+ *
+ * @return the table map for the table, not null.
+ *
+ * @throws TorqueException if the database or table is unknown.
+ */
+ public static TableMap getTableMap(String tableName, String dbName)
+ throws TorqueException
+ {
+
+ if (dbName == null)
+ {
+ dbName = Torque.getDefaultDB();
+ }
+ DatabaseMap databaseMap = Torque.getDatabaseMap(dbName);
+ if (databaseMap == null)
+ {
+ throw new TorqueException("Could not find database map"
+ + " for database "
+ + dbName);
+ }
+ String unqualifiedTableName = getUnqualifiedName(tableName, dbName);
+ TableMap result = databaseMap.getTable(unqualifiedTableName);
+ if (result == null)
+ {
+ throw new TorqueException("Could not find table "
+ + tableName
+ + " in database map of database "
+ + dbName);
+ }
+ return result;
+ }
+
+ /**
* Returns the database name of a column
* @param tableName the name of a table
* or the alias for a table
@@ -731,7 +829,7 @@ public final class SqlBuilder
*/
static Column resolveAliasAndAsColumnAndSchema(
final Column columnToResolve,
- final CriteriaInterface criteria,
+ final CriteriaInterface<?> criteria,
Database database)
throws TorqueException
{
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java?rev=1231667&r1=1231666&r2=1231667&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeer.java
Sun Jan 15 14:00:18 2012
@@ -90,6 +90,9 @@ public abstract class BasePeer
* @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,
@@ -99,9 +102,7 @@ public abstract class BasePeer
}
/**
- * Convenience method that uses straight JDBC to delete multiple
- * rows. Village throws an Exception when multiple rows are
- * deleted.
+ * Convenience method that uses straight JDBC to delete multiple rows.
*
* @param con A Connection.
* @param table The table to delete records from.
@@ -130,8 +131,7 @@ public abstract class BasePeer
/**
* Convenience method that uses straight JDBC to delete multiple
- * rows. Village throws an Exception when multiple rows are
- * deleted. This method attempts to get the default database from
+ * rows. This method attempts to get the default database from
* the pool.
*
* @param table The table to delete records from.
@@ -155,8 +155,7 @@ public abstract class BasePeer
}
/**
- * 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.
*
@@ -164,8 +163,11 @@ public abstract class BasePeer
*
* @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).
+ * Please use doDelete(org.apache.torque.criteria.Criteria,
+ * TableMap).
+ * This method will be removed in a future version of Torque.
*/
public static int doDelete(Criteria criteria) throws TorqueException
{
@@ -173,30 +175,27 @@ public abstract class BasePeer
}
/**
- * Method to perform deletes based on values and keys in a
- * Criteria.
- * This method is protected because it may cause ambiguity between
- * doDelete(Criteria,Connection) and this method. It will be made public
- * once doDelete(Criteria, Connection) is removed.
+ * 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.
*
* @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.
*/
- public static int doDelete(Criteria criteria, String tableName)
+ public static int doDelete(org.apache.torque.criteria.Criteria criteria)
throws TorqueException
{
- return getBasePeerImpl().doDelete(criteria, tableName);
+ return getBasePeerImpl().doDelete(criteria);
}
/**
- * 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 A Connection.
@@ -207,7 +206,9 @@ public abstract class BasePeer
* rethrown wrapped into a TorqueException.
*
* @deprecated This method causes unexpected results when joins are used.
- * Please use doDelete(Criteria, String, Connection).
+ * Please use doDelete(org.apache.torque.criteria.Criteria,
+ * TableMap, Connection).
+ * This method will be removed in a future version of Torque.
*/
public static int doDelete(Criteria criteria, Connection con)
throws TorqueException
@@ -216,7 +217,74 @@ public abstract class BasePeer
}
/**
- * 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 A Connection.
+ *
+ * @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.
+ */
+ public static int doDelete(org.apache.torque.criteria.Criteria criteria,
+ Connection con)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doDelete(criteria, con);
+ }
+
+ /**
+ * Method to perform deletes based on conditions in a Criteria.
+ *
+ * @param criteria The criteria to use.
+ * @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.
+ *
+ * @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 static int doDelete(Criteria criteria, TableMap tableMap)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doDelete(criteria, tableMap);
+ }
+
+ /**
+ * Method to perform deletes based on conditions in a Criteria.
+ *
+ * @param criteria The criteria to use.
+ * @param tableName 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.
+ *
+ * @return the number of deleted rows.
+ *
+ * @throws TorqueException Any exceptions caught during processing will be
+ * rethrown wrapped into a TorqueException.
+ */
+ public static int doDelete(
+ org.apache.torque.criteria.Criteria criteria,
+ TableMap tableMap)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doDelete(criteria, tableMap);
+ }
+
+ /**
+ * Method to perform deletes based on conditions in a Criteria.
*
* @param criteria The criteria to select the records to be deleted,
* not null.
@@ -225,14 +293,38 @@ public abstract class BasePeer
*
* @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 static int doDelete(
Criteria criteria,
- String tableName,
+ TableMap tableMap,
+ Connection connection)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doDelete(criteria, tableMap, connection);
+ }
+
+ /**
+ * Method to perform deletes based on values and keys in a Criteria.
+ *
+ * @param criteria The criteria to select the records to be deleted,
+ * not null.
+ * @param tableMap the table to delete records from, not null.
+ * @param con The database connection for deletion, not null.
+ *
+ * @throws TorqueException Any exceptions caught during processing will be
+ * rethrown wrapped into a TorqueException.
+ */
+ public static int doDelete(
+ org.apache.torque.criteria.Criteria criteria,
+ TableMap tableMap,
Connection connection)
throws TorqueException
{
- return getBasePeerImpl().doDelete(criteria, tableName, connection);
+ return getBasePeerImpl().doDelete(criteria, tableMap, connection);
}
/**
@@ -304,6 +396,10 @@ public abstract class BasePeer
* @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 static <T> List<T> doSelect(
Criteria criteria,
@@ -317,6 +413,88 @@ public abstract class BasePeer
/**
* 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 static <T> List<T> doSelect(
+ org.apache.torque.criteria.Criteria criteria,
+ RecordMapper<T> mapper,
+ TableMap defaultTableMap)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doSelect(criteria, mapper, defaultTableMap);
+ }
+
+ /**
+ * 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, 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, Connection).
+ * This method will be removed in a future version of Torque.
+ */
+ public static <T> List<T> doSelect(
+ Criteria criteria,
+ RecordMapper<T> mapper,
+ TableMap defaultTableMap,
+ Connection connection)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doSelect(
+ criteria,
+ mapper,
+ defaultTableMap,
+ connection);
+ }
+
+ /**
+ * 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, 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 static <T> List<T> doSelect(
+ org.apache.torque.criteria.Criteria criteria,
+ RecordMapper<T> mapper,
+ TableMap defaultTableMap,
+ Connection connection)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doSelect(
+ criteria,
+ mapper,
+ defaultTableMap,
+ 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.
@@ -372,11 +550,10 @@ public abstract class BasePeer
}
/**
- * 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.
+ * Updates rows in the DB. Checks if a <i>single</i> primary key
+ * is specified in the updateValues 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>
@@ -401,11 +578,10 @@ public abstract class BasePeer
}
/**
- * 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.
+ * Updates rows in the DB. Checks if a <i>single</i> primary key
+ * is specified in the updateValues 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>
@@ -447,6 +623,10 @@ public abstract class BasePeer
* @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 static int doUpdate(
Criteria selectCriteria,
@@ -463,11 +643,35 @@ public abstract class BasePeer
*
* @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 static int doUpdate(
+ org.apache.torque.criteria.Criteria selectCriteria,
+ ColumnValues updateValues)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doUpdate(selectCriteria, updateValues);
+ }
+
+ /**
+ * 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 static int doUpdate(
Criteria criteria,
@@ -479,16 +683,39 @@ public abstract class BasePeer
}
/**
- * Utility method which executes a given sql statement. This
+ * 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.
+ */
+ public static int doUpdate(
+ org.apache.torque.criteria.Criteria criteria,
+ ColumnValues updateValues,
+ Connection connection)
+ throws TorqueException
+ {
+ return getBasePeerImpl().doUpdate(criteria, updateValues, connection);
+ }
+
+ /**
+ * Utility method which executes a given SQL statement. This
* method should be used for update, insert, and delete
* statements. Use executeQuery() for selects.
*
- * @param statementString A String with the sql statement to execute.
+ * @param statementString A String with the SQL statement to execute.
* @return The number of rows affected.
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
- public static int executeStatement(String statementString) throws
TorqueException
+ public static int executeStatement(String statementString)
+ throws TorqueException
{
return getBasePeerImpl().executeStatement(statementString);
}
@@ -505,7 +732,7 @@ public abstract class BasePeer
* rethrown wrapped into a TorqueException.
*/
public static int executeStatement(String statementString, String dbName)
- throws TorqueException
+ throws TorqueException
{
return getBasePeerImpl().executeStatement(statementString, dbName);
}
@@ -522,37 +749,35 @@ public abstract class BasePeer
* rethrown wrapped into a TorqueException.
*/
public static int executeStatement(String statementString, Connection con)
- throws TorqueException
+ throws TorqueException
{
return getBasePeerImpl().executeStatement(statementString, con);
}
/**
- * Performs a SQL <code>select</code> using a PreparedStatement.
+ * 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 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 criteria The criteria 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.
*
- * @return The results of the query, not null.
- * @throws TorqueException Error performing database query.
+ * @deprecated Please use correctBooleans(
+ * org.apache.torque.criteria.Criteria, TableMap).
+ * This method will be removed in a future version of Torque.
*/
- public static <T> List<T> doSelect(
- Criteria criteria,
- RecordMapper<T> mapper,
- TableMap defaultTableMap,
- Connection connection)
- throws TorqueException
+ public static void correctBooleans(
+ Criteria criteria,
+ TableMap defaultTableMap)
+ throws TorqueException
{
- return getBasePeerImpl().doSelect(
- criteria,
- mapper,
- defaultTableMap,
- connection);
+ getBasePeerImpl().correctBooleans(criteria, defaultTableMap);
}
/**
@@ -570,9 +795,9 @@ public abstract class BasePeer
* retrieved.
*/
public static void correctBooleans(
- Criteria criteria,
- TableMap defaultTableMap)
- throws TorqueException
+ org.apache.torque.criteria.Criteria criteria,
+ TableMap defaultTableMap)
+ throws TorqueException
{
getBasePeerImpl().correctBooleans(criteria, defaultTableMap);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]