Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.torque.util
Class BasePeer

    java.lang.Object
      org.apache.torque.util.BasePeer

All Implemented Interfaces:
  Serializable

Deprecated. This class is not used any more as base class for the generated Peer classes and will be removed in a future version of Torque.

    @Deprecated
    public abstract class BasePeer

extends Object
implements Serializable

This is the base class for all Peer classes in the system. Peer classes are responsible for isolating all of the database access for a specific business object. They execute all of the SQL against the database. Over time this class has grown to include utility methods which ease execution of cross-database queries and the implementation of concrete Peers.

Version:
  $Id: BasePeer.java 1415362 2012-11-29 20:33:52Z tfischer $
Author:
  Frank Y. Kim, John D. McNally, Brett McLaughlin, Stephen Haberman, Martin Poeschl, Augustin Vidovic, Henning P. Schmiedehausen
See Also:
  Serialized Form

Constructor Summary
`BasePeer()` Deprecated.

Method Summary
`static void` | `correctBooleans(ColumnValues columnValues)` Deprecated. Checks all columns in the criteria to see whether booleanchar and booleanint columns are queried with a boolean.
`static void` | `correctBooleans(Criteria criteria)` Deprecated. Please use correctBooleans( org.apache.torque.criteria.Criteria, TableMap). This method will be removed in a future version of Torque.
`static void` | `correctBooleans(Criteria criteria)` Deprecated. Checks all columns in the criteria to see whether booleanchar and booleanint columns are queried with a boolean.
`static int` | `deleteAll(Connection con, String table, String column, int value)` Deprecated. The value is not SQL escaped. Better use doDelete(Criteria, String, Connection) for automatic escaping and more flexibility. This method will be removed in a future version of Torque.
`static int` | `deleteAll(String table, String column, int value)` Deprecated. The value is not SQL escaped. Better use doDelete(Criteria, String) for automatic escaping and more flexibility. This method will be removed in a future version of Torque.
`static int` | `doDelete(Criteria criteria)` 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.
`static int` | `doDelete(Criteria criteria)` 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.
`static int` | `doDelete(Criteria criteria, Connection con)` 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.
`static int` | `doDelete(Criteria criteria, Connection con)` 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.
`static ObjectKey` | `doInsert(ColumnValues insertValues)` Deprecated. Inserts a record into a database table.
`static ObjectKey` | `doInsert(ColumnValues insertValues, Connection connection)` Deprecated. Inserts a record into a database table.
`static
`<T> List<T>`
` | `doSelect(Criteria criteria, RecordMapper<T> mapper)` Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper, TableMap). This method will be removed in a future version of Torque.
`static
`<T> List<T>`
` | `doSelect(Criteria criteria, RecordMapper<T> mapper)` Deprecated. Selects rows from a database an maps them to objects.
`static
`<T> List<T>`
` | `doSelect(Criteria criteria, RecordMapper<T> mapper, Connection connection)` Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper, TableMap, Connection). This method will be removed in a future version of Torque.
`static
`<T> List<T>`
` | `doSelect(Criteria criteria, RecordMapper<T> mapper, Connection connection)` Deprecated. Selects rows from a database an maps them to objects.
`static
`<T> List<T>`
` | `doSelect(String query, RecordMapper<T> mapper, Connection connection)` Deprecated. Selects rows from a database an maps them to objects.
`static
`<T> List<T>`
` | `doSelect(String query, RecordMapper<T> mapper, String dbName)` Deprecated. Selects rows from a database an maps them to objects.
`static
`<T> T`
` | `doSelectSingleRecord(Criteria criteria, RecordMapper<T> mapper)` Deprecated. Selects at most a single row from a database an maps them to objects.
`static
`<T> T`
` | `doSelectSingleRecord(Criteria criteria, RecordMapper<T> mapper, Connection connection)` Deprecated. Selects at most a single row from a database an maps them to objects.
`static int` | `doUpdate(ColumnValues updateValues)` Deprecated. Updates rows in the DB.
`static int` | `doUpdate(ColumnValues updateValues, Connection connection)` Deprecated. Updates rows in the DB.
`static int` | `doUpdate(Criteria selectCriteria, ColumnValues updateValues)` Deprecated. Please use doUpdate( org.apache.torque.criteria.Criteria, ColumnValues). This method will be removed in a future version of Torque.
`static int` | `doUpdate(Criteria selectCriteria, ColumnValues updateValues)` Deprecated. Executes an update against the database.
`static int` | `doUpdate(Criteria criteria, ColumnValues updateValues, Connection connection)` Deprecated. Please use doUpdate(org.apache.torque.criteria.Criteria, ColumnValues, Connection). This method will be removed in a future version of Torque.
`static int` | `doUpdate(Criteria criteria, ColumnValues updateValues, Connection connection)` Deprecated. Executes an update against the database.
`static int` | `executeStatement(String statementString)` Deprecated. Utility method which executes a given SQL statement.
`static int` | `executeStatement(String statementString, Connection con)` Deprecated. Utility method which executes a given sql statement.
`static int` | `executeStatement(String statementString, String dbName)` Deprecated. Utility method which executes a given sql statement.
`static
`<T> BasePeerImpl<T>`
` | `getBasePeerImpl()` Deprecated. Returns an instance of the implementation of the peer.
`String[]` | `initCriteriaKeys(String tableName, String[] columnNames)` Deprecated. This method is not used any more and will be removed in a future version of Torque.
`static void` | `setBasePeerImpl(BasePeerImpl<?> basePeerImpl)` Deprecated. Sets the implementation instance of this peer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BasePeer

    public BasePeer()

  Deprecated.

Method Detail

### getBasePeerImpl

    public static <T> BasePeerImpl<T> getBasePeerImpl()

  Deprecated.
  Returns an instance of the implementation of the peer. If no instance is currently cached, a new instance is created and cached.

  Returns:
    an instance of the implementation of the peer, not null.

### setBasePeerImpl

    public static void setBasePeerImpl(BasePeerImpl<?> basePeerImpl)

  Deprecated.
  Sets the implementation instance of this peer.

  Parameters:
    `basePeerImpl` - the implementation, or null to force creation of a new instance.

### initCriteriaKeys

    @Deprecated
    public String[] initCriteriaKeys(String tableName,
                                                String[] columnNames)

  Deprecated. This method is not used any more and will be removed in a future version of Torque.

  Convenience method to create a String array of criteria keys.

  Parameters:
    `tableName` - Name of table.
    `columnNames` - A String[].
  Returns:
    A String[].

### deleteAll

    @Deprecated
    public static int deleteAll(Connection con,
                                           String table,
                                           String column,
                                           int value)
                         throws TorqueException

  Deprecated. The value is not SQL escaped. Better use doDelete(Criteria, String, Connection) for automatic escaping and more flexibility. This method will be removed in a future version of Torque.

  Convenience method that uses straight JDBC to delete multiple rows.

  Parameters:
    `con` - A Connection.
    `table` - The table to delete records from.
    `column` - The column in the where clause.
    `value` - The value of the column.
  Returns:
    the number of deleted rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### deleteAll

    @Deprecated
    public static int deleteAll(String table,
                                           String column,
                                           int value)
                         throws TorqueException

  Deprecated. The value is not SQL escaped. Better use doDelete(Criteria, String) for automatic escaping and more flexibility. This method will be removed in a future version of Torque.

  Convenience method that uses straight JDBC to delete multiple rows. This method attempts to get the default database from the pool.

  Parameters:
    `table` - The table to delete records from.
    `column` - The column in the where clause.
    `value` - The value of the column.
  Returns:
    the number of deleted rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doDelete

    @Deprecated
    public static int doDelete(Criteria criteria)
                        throws 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.

  Method to perform deletes based on conditions in a Criteria.

  Parameters:
    `criteria` - The criteria to use.
  Returns:
    the number of deleted rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doDelete

    @Deprecated
    public static int doDelete(Criteria criteria)
                        throws 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.

  Method to perform deletes based on conditions in a Criteria.

  Parameters:
    `criteria` - The criteria to use.
  Returns:
    the number of deleted rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doDelete

    @Deprecated
    public static int doDelete(Criteria criteria,
                                          Connection con)
                        throws 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.

  Method to perform deletes based on conditions in a Criteria.

  Parameters:
    `criteria` - The criteria to use.
    `con` - A Connection.
  Returns:
    the number of deleted rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doDelete

    @Deprecated
    public static int doDelete(Criteria criteria,
                                          Connection con)
                        throws 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.

  Method to perform deletes based on conditions in a Criteria.

  Parameters:
    `criteria` - The criteria to use.
    `con` - A Connection.
  Returns:
    the number of deleted rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doInsert

    public static ObjectKey doInsert(ColumnValues insertValues)
                              throws TorqueException

  Deprecated.
  Inserts a record into a database table.

  If the primary key is included in Criteria, then that value will be used to insert the row.

  Otherwise, if the primary key can be generated automatically, the generated key will be used for the insert and will be returned.

  If no value is given for the primary key is defined and it cannot be generated automatically or the table has no primary key, the values will be inserted as specified and null will be returned.

  Parameters:
    `insertValues` - Contains the values to insert, not null.
  Returns:
    the primary key of the inserted row (if the table has a primary key) or null (if the table does not have a primary key).
  Throws:
    `TorqueException` - if a database error occurs.

### doInsert

    public static ObjectKey doInsert(ColumnValues insertValues,
                                     Connection connection)
                              throws TorqueException

  Deprecated.
  Inserts a record into a database table.

  If the primary key is included in Criteria, then that value will be used to insert the row.

  Otherwise, if the primary key can be generated automatically, the generated key will be used for the insert and will be returned.

  If no value is given for the primary key is defined and it cannot be generated automatically or the table has no primary key, the values will be inserted as specified and null will be returned.

  Parameters:
    `insertValues` - Contains the values to insert, not null.
    `connection` - the connection to use for the insert, not null.
  Returns:
    the primary key of the inserted row (if the table has a primary key) or null (if the table does not have a primary key).
  Throws:
    `TorqueException` - if a database error occurs.

### doSelect

    @Deprecated
    public static <T> List<T> doSelect(Criteria criteria,
                                                  RecordMapper<T> mapper)
                            throws TorqueException

  Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper, TableMap). This method will be removed in a future version of Torque.

  Selects rows from a database an maps them to objects.

  Parameters:
    `criteria` - A Criteria specifying the records to select, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
  Returns:
    The results of the query, not null.
  Throws:
    `TorqueException` - if querying the database fails.

### doSelect

    public static <T> List<T> doSelect(Criteria criteria,
                                       RecordMapper<T> mapper)
                            throws TorqueException

  Deprecated.
  Selects rows from a database an maps them to objects.

  Parameters:
    `criteria` - A Criteria specifying the records to select, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
  Returns:
    The results of the query, not null.
  Throws:
    `TorqueException` - if querying the database fails.

### doSelect

    @Deprecated
    public static <T> List<T> doSelect(Criteria criteria,
                                                  RecordMapper<T> mapper,
                                                  Connection connection)
                            throws TorqueException

  Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper, TableMap, Connection). This method will be removed in a future version of Torque.

  Selects rows from a database an maps them to objects.

  Parameters:
    `criteria` - A Criteria specifying the records to select, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
    `connection` - the database connection for selecting records, not null.
  Returns:
    The results of the query, not null.
  Throws:
    `TorqueException` - Error performing database query.

### doSelect

    public static <T> List<T> doSelect(Criteria criteria,
                                       RecordMapper<T> mapper,
                                       Connection connection)
                            throws TorqueException

  Deprecated.
  Selects rows from a database an maps them to objects.

  Parameters:
    `criteria` - A Criteria specifying the records to select, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
    `connection` - the database connection for selecting records, not null.
  Returns:
    The results of the query, not null.
  Throws:
    `TorqueException` - Error performing database query.

### doSelect

    public static <T> List<T> doSelect(String query,
                                       RecordMapper<T> mapper,
                                       String dbName)
                            throws TorqueException

  Deprecated.
  Selects rows from a database an maps them to objects.

  Parameters:
    `query` - the sql query to execute, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
    `dbName` - The name of the database to create the connection for, or null for the default SDB.
  Returns:
    The results of the query, not null.
  Throws:
    `TorqueException` - if querying the database fails.

### doSelect

    public static <T> List<T> doSelect(String query,
                                       RecordMapper<T> mapper,
                                       Connection connection)
                            throws TorqueException

  Deprecated.
  Selects rows from a database an maps them to objects.

  Parameters:
    `query` - the SQL Query to execute, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
    `connection` - the database connection, not null.
  Returns:
    The results of the query, not null.
  Throws:
    `TorqueException` - if querying the database fails.

### doSelectSingleRecord

    public static <T> T doSelectSingleRecord(Criteria criteria,
                                             RecordMapper<T> mapper)
                                  throws TorqueException

  Deprecated.
  Selects at most a single row from a database an maps them to objects.

  Parameters:
    `criteria` - A Criteria specifying the records to select, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
  Returns:
    The selected row, or null if no records was selected.
  Throws:
    `TorqueException` - if querying the database fails.

### doSelectSingleRecord

    public static <T> T doSelectSingleRecord(Criteria criteria,
                                             RecordMapper<T> mapper,
                                             Connection connection)
                                  throws TorqueException

  Deprecated.
  Selects at most a single row from a database an maps them to objects.

  Parameters:
    `criteria` - A Criteria specifying the records to select, not null.
    `mapper` - The mapper creating the objects from the resultSet, not null.
    `connection` - the database connection, not null.
  Returns:
    The selected row, or null if no records was selected.
  Throws:
    `TorqueException` - if querying the database fails.

### doUpdate

    public static int doUpdate(ColumnValues updateValues)
                        throws TorqueException

  Deprecated.
  Updates rows in the DB. Checks if a single 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.

  Use this method for performing an update of the kind:

  "WHERE primary_key_id = someValue"

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

  Parameters:
    `updateValues` - Which columns to update with which values for which primary key value, not null.
  Returns:
    the number of affected rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doUpdate

    public static int doUpdate(ColumnValues updateValues,
                               Connection connection)
                        throws TorqueException

  Deprecated.
  Updates rows in the DB. Checks if a single 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.

  Use this method for performing an update of the kind:

  "WHERE primary_key_id = someValue"

  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, Connection).

  Parameters:
    `updateValues` - Which columns to update with which values for which primary key value, not null.
    `connection` - the database connection to use.
  Returns:
    the number of affected rows.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### doUpdate

    @Deprecated
    public static int doUpdate(Criteria selectCriteria,
                                          ColumnValues updateValues)
                        throws TorqueException

  Deprecated. Please use doUpdate( org.apache.torque.criteria.Criteria, ColumnValues). This method will be removed in a future version of Torque.

  Executes an update against the database. The rows to be updated are selected using `criteria` and updated using the values in `updateValues`.

  Parameters:
    `selectCriteria` - selects which rows of which table should be updated, not null.
    `updateValues` - Which columns to update with which values, not null.
  Returns:
    the number of affected rows.
  Throws:
    `TorqueException` - if updating fails.

### doUpdate

    public static int doUpdate(Criteria selectCriteria,
                               ColumnValues updateValues)
                        throws TorqueException

  Deprecated.
  Executes an update against the database. The rows to be updated are selected using `criteria` and updated using the values in `updateValues`.

  Parameters:
    `selectCriteria` - selects which rows of which table should be updated, not null.
    `updateValues` - Which columns to update with which values, not null.
  Returns:
    the number of affected rows.
  Throws:
    `TorqueException` - if updating fails.

### doUpdate

    @Deprecated
    public static int doUpdate(Criteria criteria,
                                          ColumnValues updateValues,
                                          Connection connection)
                        throws TorqueException

  Deprecated. Please use doUpdate(org.apache.torque.criteria.Criteria, ColumnValues, Connection). This method will be removed in a future version of Torque.

  Executes an update against the database. The rows to be updated are selected using `criteria` and updated using the values in `updateValues`.

  Parameters:
    `criteria` - selects which rows of which table should be updated.
    `updateValues` - Which columns to update with which values, not null.
    `connection` - the database connection to use, not null.
  Returns:
    the number of affected rows.
  Throws:
    `TorqueException` - if updating fails.

### doUpdate

    public static int doUpdate(Criteria criteria,
                               ColumnValues updateValues,
                               Connection connection)
                        throws TorqueException

  Deprecated.
  Executes an update against the database. The rows to be updated are selected using `criteria` and updated using the values in `updateValues`.

  Parameters:
    `criteria` - selects which rows of which table should be updated.
    `updateValues` - Which columns to update with which values, not null.
    `connection` - the database connection to use, not null.
  Returns:
    the number of affected rows.
  Throws:
    `TorqueException` - if updating fails.

### executeStatement

    public static int executeStatement(String statementString)
                                throws TorqueException

  Deprecated.
  Utility method which executes a given SQL statement. This method should be used for update, insert, and delete statements. Use executeQuery() for selects.

  Parameters:
    `statementString` - A String with the SQL statement to execute.
  Returns:
    The number of rows affected.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### executeStatement

    public static int executeStatement(String statementString,
                                       String dbName)
                                throws TorqueException

  Deprecated.
  Utility method which executes a given sql statement. This method should be used for update, insert, and delete statements. Use executeQuery() for selects.

  Parameters:
    `statementString` - A String with the sql statement to execute.
    `dbName` - Name of database to connect to.
  Returns:
    The number of rows affected.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### executeStatement

    public static int executeStatement(String statementString,
                                       Connection con)
                                throws TorqueException

  Deprecated.
  Utility method which executes a given sql statement. This method should be used for update, insert, and delete statements. Use executeQuery() for selects.

  Parameters:
    `statementString` - A String with the sql statement to execute.
    `con` - A Connection.
  Returns:
    The number of rows affected.
  Throws:
    `TorqueException` - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

### correctBooleans

    @Deprecated
    public static void correctBooleans(Criteria criteria)
                                throws TorqueException

  Deprecated. Please use correctBooleans( org.apache.torque.criteria.Criteria, TableMap). This method will be removed in a future version of Torque.

  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.

  Parameters:
    `criteria` - The criteria to be checked for booleanint and booleanchar columns.
  Throws:
    `TorqueException` - if the database map for the criteria cannot be retrieved.

### correctBooleans

    public static void correctBooleans(Criteria criteria)
                                throws TorqueException

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

  Parameters:
    `criteria` - The criteria to be checked for booleanint and booleanchar columns.
  Throws:
    `TorqueException` - if the database map for the criteria cannot be retrieved.

### correctBooleans

    public static void correctBooleans(ColumnValues columnValues)
                                throws TorqueException

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

  Parameters:
    `columnValues` - The value to be checked for booleanint and booleanchar columns.
  Throws:
    `TorqueException` - if the database map for the criteria cannot be retrieved.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2013 The Apache Software Foundation. All Rights Reserved.