org.apache.torque.util
Class BasePeerImpl<T>

java.lang.Object
  extended by org.apache.torque.util.BasePeerImpl<T>
Type Parameters:
T - The data object class for this Peer.
All Implemented Interfaces:
Serializable

public class BasePeerImpl<T>
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: BasePeerImpl.java 1388656 2012-09-21 19:59:16Z 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
BasePeerImpl()
          Default constructor
BasePeerImpl(RecordMapper<T> recordMapper, TableMap tableMap, String databaseName)
          Constructor providing the objects to be injected as parameters.
 
Method Summary
 void addSelectColumns(Criteria criteria)
          Add all the columns needed to create a new object.
 void addSelectColumns(Criteria criteria)
          Deprecated. Please use addSelectColumns( org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.
 void correctBooleans(ColumnValues columnValues)
          Checks all columns in the criteria to see whether booleanchar and booleanint columns are queried with a boolean.
 void correctBooleans(Criteria criteria)
          Deprecated. Please use correctBooleans( org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.
 void correctBooleans(Criteria criteria)
          Checks all columns in the criteria to see whether booleanchar and booleanint columns are queried with a boolean.
 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.
 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.
 int doDelete(Criteria criteria)
          Deletes rows from a database table.
protected  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.
 int doDelete(Criteria criteria, Connection connection)
          Deletes rows from a table.
protected  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.
 ObjectKey doInsert(ColumnValues insertValues)
          Inserts a record into a database table.
 ObjectKey doInsert(ColumnValues insertValues, Connection connection)
          Inserts a record into a database table.
 List<T> doSelect(Criteria criteria)
          Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.
 List<T> doSelect(Criteria criteria)
          Selects objects from a database.
 List<T> doSelect(Criteria criteria, Connection connection)
          Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, Connection). This method will be removed in a future version of Torque.
 List<T> doSelect(Criteria criteria, Connection connection)
          Selects objects from a database within a transaction.
<TT> List<TT>
doSelect(Criteria criteria, RecordMapper<TT> mapper)
          Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper). This method will be removed in a future version of Torque.
<TT> List<TT>
doSelect(Criteria criteria, RecordMapper<TT> mapper)
          Selects rows from a database an maps them to objects.
<TT> List<TT>
doSelect(Criteria criteria, RecordMapper<TT> mapper, Connection connection)
          Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper, Connection). This method will be removed in a future version of Torque.
<TT> List<TT>
doSelect(Criteria criteria, RecordMapper<TT> mapper, Connection connection)
          Performs a SQL select using a PreparedStatement.
 List<T> doSelect(String query)
          Selects rows from a database an maps them to objects.
<TT> List<TT>
doSelect(String query, RecordMapper<TT> mapper, String dbName)
          Selects rows from a database an maps them to objects.
<TT> List<TT>
doSelect(String query, RecordMapper<TT> mapper, String dbName, Connection connection)
          Selects rows from a database an maps them to objects.
 List<T> doSelect(String query, String dbName, Connection connection)
          Selects rows from a database an maps them to objects.
 T doSelectSingleRecord(Criteria criteria)
          Selects at most one object from a database.
 T doSelectSingleRecord(Criteria criteria, Connection connection)
          Selects at most one object from a database within a transaction.
<TT> TT
doSelectSingleRecord(Criteria criteria, RecordMapper<TT> mapper)
          Selects at most a single row from a database an maps them to objects.
<TT> TT
doSelectSingleRecord(Criteria criteria, RecordMapper<TT> mapper, Connection connection)
          Selects at most a single row from a database an maps them to objects.
 int doUpdate(ColumnValues updateValues)
          Convenience method used to update rows in the DB.
 int doUpdate(ColumnValues updateValues, Connection connection)
          Convenience method used to update rows in the DB.
 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.
 int doUpdate(Criteria selectCriteria, ColumnValues updateValues)
          Executes an update against the database.
 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.
 int doUpdate(Criteria criteria, ColumnValues updateValues, Connection connection)
          Executes an update against the database.
 int executeStatement(String statementString)
          Utility method which executes a given sql statement.
 int executeStatement(String statementString, String dbName)
          Utility method which executes a given sql statement.
 int executeStatement(String statementString, String dbName, Connection con)
          Utility method which executes a given sql statement.
 String getDatabaseName()
          Get the database name for this instance.
 RecordMapper<T> getRecordMapper()
          Get the record mapper for this instance.
 TableMap getTableMap()
          Get the default table map for this instance.
 String[] initCriteriaKeys(String tableName, String[] columnNames)
          Deprecated. This method is not used any more and will be removed in a future version of Torque.
 List<T> resultSet2Objects(ResultSet resultSet, Adapter adapter)
          Get the list of objects from a ResultSet.
 void setDatabaseName(String databaseName)
          Set the database name for this instance.
protected  void setDbName(Criteria crit)
          Sets the database name in the passed criteria to the table's default, if it is not already set.
protected  void setDbName(Criteria crit)
          Deprecated. Please use addSelectColumns( org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.
 void setRecordMapper(RecordMapper<T> recordMapper)
          Set the record mapper for this instance.
 void setTableMap(TableMap tableMap)
          Set the default table map for this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasePeerImpl

public BasePeerImpl()
Default constructor


BasePeerImpl

public BasePeerImpl(RecordMapper<T> recordMapper,
                    TableMap tableMap,
                    String databaseName)
Constructor providing the objects to be injected as parameters.

Parameters:
recordMapper - a record mapper to map JDBC result sets to objects
tableMap - the default table map
databaseName - the name of the database
Method Detail

setRecordMapper

public void setRecordMapper(RecordMapper<T> recordMapper)
Set the record mapper for this instance.

Parameters:
recordMapper - the recordMapper to set

getRecordMapper

public RecordMapper<T> getRecordMapper()
                                throws TorqueException
Get the record mapper for this instance.

Returns:
the recordMapper
Throws:
TorqueException

setTableMap

public void setTableMap(TableMap tableMap)
Set the default table map for this instance.

Parameters:
tableMap - the tableMap to set

getTableMap

public TableMap getTableMap()
                     throws TorqueException
Get the default table map for this instance.

Returns:
the tableMap
Throws:
TorqueException

setDatabaseName

public void setDatabaseName(String databaseName)
Set the database name for this instance.

Parameters:
databaseName - the databaseName to set

getDatabaseName

public String getDatabaseName()
                       throws TorqueException
Get the database name for this instance.

Returns:
the databaseName
Throws:
TorqueException

resultSet2Objects

public List<T> resultSet2Objects(ResultSet resultSet,
                                 Adapter adapter)
                          throws TorqueException
Get the list of objects from a ResultSet. Please not that the ResultSet MUST return columns in the right order. You can use getFieldNames() in BaseObject to get the correct sequence.

Parameters:
resultSet - the ResultSet to extract the objects from.
the - database adapter of the database for the result set, or null if the adapter is unknown.
Returns:
the list of objects read from the ResultSet.
Throws:
TorqueException - If the mapping fails.

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

public int doDelete(Criteria criteria)
             throws TorqueException
Deletes rows from a database table.

Parameters:
criteria - defines the rows to be deleted, not null.
Returns:
the number of deleted rows.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

doDelete

public int doDelete(Criteria criteria,
                    Connection connection)
             throws TorqueException
Deletes rows from a table. This method is to be used during a transaction, otherwise use the doDelete(Criteria) method.

Parameters:
criteria - defines the rows to be deleted, not null.
connection - the connection to use, not null.
Returns:
the number of deleted rows.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

doDelete

@Deprecated
protected 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
protected 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 a Criteria.

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

doInsert

public ObjectKey doInsert(ColumnValues insertValues)
                   throws TorqueException
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 ObjectKey doInsert(ColumnValues insertValues,
                          Connection connection)
                   throws TorqueException
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.

addSelectColumns

public void addSelectColumns(Criteria criteria)
Add all the columns needed to create a new object.

Parameters:
criteria - the Criteria to which the select columns should be added.

addSelectColumns

@Deprecated
public void addSelectColumns(Criteria criteria)
Deprecated. Please use addSelectColumns( org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.

Add all the columns needed to create a new object.

Parameters:
criteria - the Criteria to which the select columns should be added.

doSelect

@Deprecated
public List<T> doSelect(Criteria criteria)
                 throws TorqueException
Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.

Selects objects from a database.

Parameters:
criteria - object used to create the SELECT statement.
Returns:
the list of selected objects, not null.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

doSelect

public List<T> doSelect(Criteria criteria)
                 throws TorqueException
Selects objects from a database.

Parameters:
criteria - object used to create the SELECT statement.
Returns:
the list of selected objects, not null.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

doSelect

@Deprecated
public List<T> doSelect(Criteria criteria,
                                   Connection connection)
                 throws TorqueException
Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, Connection). This method will be removed in a future version of Torque.

Selects objects from a database within a transaction.

Parameters:
criteria - object used to create the SELECT statement.
connection - the connection to use, not null.
Returns:
the list of selected objects, not null.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

doSelect

public List<T> doSelect(Criteria criteria,
                        Connection connection)
                 throws TorqueException
Selects objects from a database within a transaction.

Parameters:
criteria - object used to create the SELECT statement.
connection - the connection to use, not null.
Returns:
the list of selected objects, not null.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

doSelectSingleRecord

public T doSelectSingleRecord(Criteria criteria)
                       throws TorqueException
Selects at most one object from a database.

Parameters:
criteria - object used to create the SELECT statement.
Returns:
the selected Object, or null if no object was selected.
Throws:
TorqueException - If more than one record is selected or if an error occurs when processing the query.

doSelectSingleRecord

public T doSelectSingleRecord(Criteria criteria,
                              Connection connection)
                       throws TorqueException
Selects at most one object from a database within a transaction.

Parameters:
criteria - object used to create the SELECT statement.
connection - the connection holding the transaction, not null.
Returns:
the selected Object, or null if no object was selected.
Throws:
TorqueException - If more than one record is selected or if an error occurs when processing the query.

doSelect

@Deprecated
public <TT> List<TT> doSelect(Criteria criteria,
                                         RecordMapper<TT> mapper)
                  throws TorqueException
Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper). 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 <TT> List<TT> doSelect(Criteria criteria,
                              RecordMapper<TT> mapper)
                  throws TorqueException
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 List<T> doSelect(String query)
                 throws TorqueException
Selects rows from a database an maps them to objects.

Parameters:
query - the sql query to execute, not null.
Returns:
The results of the query, not null.
Throws:
TorqueException - if querying the database fails.

doSelect

public List<T> doSelect(String query,
                        String dbName,
                        Connection connection)
                 throws TorqueException
Selects rows from a database an maps them to objects.

Parameters:
query - the SQL Query to execute, not null.
dbName - The name of the database to select from, or null for the default DB.
connection - the database connection, not null.
Returns:
The results of the query, not null.
Throws:
TorqueException - if querying the database fails.

doSelect

public <TT> List<TT> doSelect(String query,
                              RecordMapper<TT> mapper,
                              String dbName)
                  throws TorqueException
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 DB.
Returns:
The results of the query, not null.
Throws:
TorqueException - if querying the database fails.

doSelect

public <TT> List<TT> doSelect(String query,
                              RecordMapper<TT> mapper,
                              String dbName,
                              Connection connection)
                  throws TorqueException
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 DB.
connection - the database connection, not null.
Returns:
The results of the query, not null.
Throws:
TorqueException - if querying the database fails.

doSelect

@Deprecated
public <TT> List<TT> doSelect(Criteria criteria,
                                         RecordMapper<TT> mapper,
                                         Connection connection)
                  throws TorqueException
Deprecated. Please use doSelect(org.apache.torque.criteria.Criteria, RecordMapper, Connection). This method will be removed in a future version of Torque.

Performs a SQL select using a PreparedStatement.

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 <TT> List<TT> doSelect(Criteria criteria,
                              RecordMapper<TT> mapper,
                              Connection connection)
                  throws TorqueException
Performs a SQL select using a PreparedStatement.

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.

doSelectSingleRecord

public <TT> TT doSelectSingleRecord(Criteria criteria,
                                    RecordMapper<TT> mapper)
                        throws TorqueException
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 <TT> TT doSelectSingleRecord(Criteria criteria,
                                    RecordMapper<TT> mapper,
                                    Connection connection)
                        throws TorqueException
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 int doUpdate(ColumnValues updateValues)
             throws TorqueException
Convenience method used to update rows in the DB. Checks if a single 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.

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 int doUpdate(ColumnValues updateValues,
                    Connection connection)
             throws TorqueException
Convenience method used to update rows in the DB. Checks if a single 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.

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 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 int doUpdate(Criteria selectCriteria,
                    ColumnValues updateValues)
             throws TorqueException
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 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 int doUpdate(Criteria criteria,
                    ColumnValues updateValues,
                    Connection connection)
             throws TorqueException
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 int executeStatement(String statementString)
                     throws TorqueException
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 int executeStatement(String statementString,
                            String dbName)
                     throws TorqueException
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 - The name of the database to execute the statement against, or null for the default DB.
Returns:
The number of rows affected.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

executeStatement

public int executeStatement(String statementString,
                            String dbName,
                            Connection con)
                     throws TorqueException
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 - The name of the database to execute the statement against, or null for the default DB.
con - The database connection to use.
Returns:
The number of rows affected.
Throws:
TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.

correctBooleans

@Deprecated
public void correctBooleans(Criteria criteria)
                     throws TorqueException
Deprecated. Please use correctBooleans( org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.

Changes the boolean values in the criteria to the appropriate type, whenever a booleanchar or booleanint column is involved. This enables the user to create criteria using Boolean values for booleanchar or booleanint columns.

Parameters:
criteria - the criteria in which the boolean values should be corrected.
Throws:
TorqueException - if the database map for the criteria cannot be obtained.

correctBooleans

public void correctBooleans(Criteria criteria)
                     throws TorqueException
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 void correctBooleans(ColumnValues columnValues)
                     throws TorqueException
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.

setDbName

protected void setDbName(Criteria crit)
                  throws TorqueException
Sets the database name in the passed criteria to the table's default, if it is not already set.

Parameters:
crit - the criteria to set the database name in, not null.
Throws:
TorqueException

setDbName

@Deprecated
protected void setDbName(Criteria crit)
                  throws TorqueException
Deprecated. Please use addSelectColumns( org.apache.torque.criteria.Criteria). This method will be removed in a future version of Torque.

Sets the database name in the passed criteria to the table's default, if it is not already set.

Parameters:
crit - the criteria to set the database name in, not null.
Throws:
TorqueException


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