Klasse AbstractPeerImpl<T extends ObjectModel>

java.lang.Object
org.apache.torque.util.BasePeerImpl<T>
org.apache.torque.util.AbstractPeerImpl<T>
Typparameter:
T - The data object class for this Peer.
Alle implementierten Schnittstellen:
Serializable

public abstract class AbstractPeerImpl<T extends ObjectModel> extends BasePeerImpl<T>
This is an abstract layer for all generated peer classes that implements several convenience methods that otherwise would have to be generated.
Version:
$Id: BasePeerImpl.java 1701342 2015-09-05 02:18:04Z tfischer $
Autor:
Thomas Vandahl
Siehe auch:
  • Konstruktordetails

    • AbstractPeerImpl

      public AbstractPeerImpl()
      Default constructor
    • AbstractPeerImpl

      public AbstractPeerImpl(RecordMapper<T> recordMapper, TableMap tableMap, String databaseName)
      Constructor providing the objects to be injected as parameters.
      Parameter:
      recordMapper - a record mapper to map JDBC result sets to objects
      tableMap - the default table map
      databaseName - the name of the database
  • Methodendetails

    • buildCriteria

      public abstract Criteria buildCriteria(T obj)
      Build a Criteria object from the data object for this peer.
      Parameter:
      obj - the object to build the criteria from, not null.
      Gibt zurück:
      Criteria object
    • buildSelectCriteria

      public abstract Criteria buildSelectCriteria(T obj)
      Build a Criteria object from the data object for this peer, skipping all binary columns.
      Parameter:
      obj - the object to build the criteria from, not null.
      Gibt zurück:
      Criteria object
    • buildCriteria

      public Criteria buildCriteria(ObjectKey<?> pk)
      Build a Criteria object which selects all objects which have a given primary key. This method should never be called because if the table has a primary key, it must be overridden in the generated code.
      Parameter:
      pk - the primary key value to build the criteria from, not null.
      Gibt zurück:
      Criteria object
    • buildColumnValues

      public abstract ColumnValues buildColumnValues(T obj) throws TorqueException
      Returns the contents of the object as ColumnValues object. Primary key columns which are generated on insertion are not added to the returned object if they still have their initial value. Also, columns which have the useDatabaseDefaultValue flag set to true are also not added to the returned object if they still have their initial value.
      Parameter:
      obj - the object to build the column values from
      Gibt zurück:
      ColumnValues object
      Löst aus:
      TorqueException - if the table map cannot be retrieved (should not happen).
    • doSelect

      public List<T> doSelect(T obj) throws TorqueException
      Selects objects from the database which have the same content as the passed object.
      Parameter:
      obj - the data object
      Gibt zurück:
      The list of selected objects, not null.
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doSelectSingleRecord

      public T doSelectSingleRecord(T obj) throws TorqueException
      Selects at most one object from the database which has the same content as the passed object.
      Parameter:
      obj - the data object
      Gibt zurück:
      the selected Object, or null if no object was selected.
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doInsert

      public ObjectKey<?> doInsert(ColumnValues columnValues, Connection con) throws TorqueException
      Method to do inserts. This method is to be used during a transaction, otherwise use the doInsert(Criteria) method.
      Setzt außer Kraft:
      doInsert in Klasse BasePeerImpl<T extends ObjectModel>
      Parameter:
      columnValues - the values to insert.
      con - the connection to use, not null.
      Gibt zurück:
      the primary key of the inserted row or null if the table has no primary key
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doInsert

      public void doInsert(T obj) throws TorqueException
      Method to do inserts
      Parameter:
      obj - the data object
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doInsert

      public void doInsert(T obj, Connection con) throws TorqueException
      Method to do inserts. This method is to be used during a transaction, otherwise use the doInsert(T) method. It will take care of the connection details internally.
      Parameter:
      obj - the data object to insert into the database.
      con - the connection to use
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doUpdate

      public int doUpdate(T obj) throws TorqueException
      Updates an object in the database. The primary key is used to identify the object to update.
      Parameter:
      obj - the data object to update in the database.
      Gibt zurück:
      the number of affected rows.
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doUpdate

      public int doUpdate(T obj, Connection con) throws TorqueException
      Updates an object in the database. The primary key is used to identify the object to update. This method is to be used during a transaction, otherwise the doUpdate(T) method can be used.
      Parameter:
      obj - the data object to update in the database.
      con - the connection to use, not null.
      Gibt zurück:
      the number of affected rows.
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doDelete

      public int doDelete(ObjectKey<?> pk) throws TorqueException
      Deletes a row in the database.
      Parameter:
      pk - the ObjectKey that identifies the row to delete.
      Gibt zurück:
      the number of deleted rows.
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.
    • doDelete

      public int doDelete(ObjectKey<?> pk, Connection con) throws TorqueException
      Deletes a row in the database. This method is to be used during a transaction, otherwise use the doDelete(ObjectKey) method.
      Parameter:
      pk - the ObjectKey that identifies the row to delete.
      con - the connection to use for deleting, not null.
      Gibt zurück:
      the number of deleted rows.
      Löst aus:
      TorqueException - Any exceptions caught during processing will be rethrown wrapped into a TorqueException.