PAJES 2.3.9

org.pajes.db.entity
Class Manager

java.lang.Object
  extended byorg.pajes.db.entity.Manager
All Implemented Interfaces:
java.io.Serializable

public abstract class Manager
extends java.lang.Object
implements java.io.Serializable

Provides the data access layer for Entity instances.

Sub-classes must define an Attributes field for each column in the database table that is to be considered as part of the entity.

For example, given following SQL table:

  create table client
  (
     client                int                   not null,
     clientName            varchar(50)           not null,
     constraint clientPK primary key (client)
  )
 

you would create an Manager sub-class as:

  import org.pajes.db.entity.Manager;
  import org.pajes.db.entity.Attributes;
  import org.pajes.db.entity.Registry;
  import java.sql.Types;
  public class ClientManager extends Manager {
      private Attributes client = new Attributes(this, "client", "client", Types.INTEGER, true, false);
      private Attributes clientName = new Attributes(this, "clientName", "client", Types.VARCHAR, false, false);
      public ClientManager(ConnectionPool pool) {
          super(Client.class, "client", pool);
          this.setOrderByColumns("client");
      }
  }
 

See Also:
Serialized Form

Field Summary
static java.lang.String EDITOR_FACTORY
          Deprecated. Moved to DefaultEditor.EDITOR_FACTORY
static java.lang.String LISTER_FACTORY
          Deprecated. Moved to DefaultLister.LISTER_FACTORY
 
Constructor Summary
Manager(java.lang.Class entity, java.lang.String table, ConnectionManager manager)
          Creates an Manager for managing the specified Entity objects.
Manager(java.lang.Class entity, java.lang.String table, ConnectionPool pool)
          Creates an Manager for managing the specified Entity objects.
 
Method Summary
 Entity create()
          Creates a new Entity instance.
 int delete(Entity entity)
          Deletes an entity from the database table.
 int delete(Entity entity, java.sql.Connection connection)
          Deletes an entity from the database table.
 int delete(Scope scope)
          Delete entities that match the specified Scope from the table.
 int delete(Scope scope, java.sql.Connection connection)
          Delete entities that match the specified Scope from the table.
 java.lang.String getAdminServletName()
          Returns the MaintenanceServlet class name that is used to administer the Entity objects managed by this class.
 URI getAdminServletURI()
          Returns the URI of the MaintenanceServlet that is used to administer the Entity objects managed by this class.
 java.util.HashMap getAttributes()
          Returns the entity attributes as a HashMap, with the UPPER CASE column name as the key and the Attributes objects as the associated value.
 java.lang.String[] getColumnNames()
          Returns the names of all the defined columns.
protected  int getColumnPosition(java.lang.Class defaultClass, Attributes attributes)
          Called when an Attributes object is registered with the Manager to determine the default location of the column in the DefaultEditor, DefaultLister and DefaultViewer.
 ConnectionPool getConnectionPool()
          Returns the connection pool from which a database connection may be requested.
 java.sql.Connection getDBConnection()
          Convenience method to return a free connection from the connection pool.
 Paje getEditor(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, boolean isNew)
          Returns a Paje to display and/or edit an Entity object.
protected  java.lang.Class getEntity()
          Retuuns the class from which a new instance will be returned when creating a new entity.
 Paje getLister(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
          Returns a Paje to display a list of Entity objects.
 java.lang.String getOrderByClause()
          Returns the ORDER BY clause to sort the result set.
 java.lang.String[] getPrimaryKeys()
          Returns the names of the defined primary keys, or if no primary keys have been defined, the names of all columns.
 java.lang.String getPrimaryKeyValues(Entity entity)
          Returns a String that should uniquely identify the specified Entity.
 java.lang.String getPrimaryKeyValues(javax.servlet.http.HttpServletRequest request)
          Returns a String that should uniquely identify an Entity.
protected  java.sql.PreparedStatement getSQLDeleteStatement(Entity entity, java.sql.Connection connection)
          Returns the SQL PreparedStatement string that will deletes the specified entity from the table.
protected  java.sql.PreparedStatement getSQLDeleteStatement(Scope scope, java.sql.Connection connection)
          Returns the SQL PreparedStatement string that will delete entities that match the specified Scope from the table.
protected  java.sql.PreparedStatement getSQLInsertStatement(Entity entity, java.sql.Connection connection)
          Returns the SQL PreparedStatement string that will inserts the specified entity into the table.
protected  java.sql.PreparedStatement getSQLSelectStatement(Scope scope, java.sql.Connection connection)
          Returns the SQL PreparedStatement string that will select entities that match the specified Scope from the table.
protected  java.sql.PreparedStatement getSQLUpdateStatement(Entity entity, java.sql.Connection connection)
          Returns the SQL PreparedStatement string that will updates the specified entity in the table.
 java.lang.String getTableName()
          Retrieves the name of the database table that this object manages.
 Paje getViewer(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
          Returns a Paje to display an Entity object.
 int insert(Entity entity)
          Inserts an entity into the database table.
 int insert(Entity entity, java.sql.Connection connection)
          Inserts an entity into the database table.
protected static java.lang.String makePrimaryKeyString(java.lang.Class entity, java.lang.String[] keys, java.lang.Object[] values)
          Returns a String that should uniquely identify an Entity.
protected  void onCacheEntity(Entity entity)
          Called immediately after an individual entity is cached.
protected  void onCacheRefresh(java.sql.Connection connection)
          Called immediately after a cache refresh.
 void recache()
          Refreshes the local cache, it one exists.
 Entity retrieve(Scope scope)
          Retrieves a single entity.
 Entity retrieve(Scope scope, int record)
          Retrieves a single entity.
 Entity retrieve(Scope scope, int record, java.sql.Connection connection)
          Retrieves a single entity.
 int retrieveCount(Scope scope)
          Retrieves the count of Entities that meet the scope criteria.
 int retrieveCount(Scope scope, java.sql.Connection connection)
          Retrieves the count of Entities that meet the scope criteria.
protected  Entity retrievedEntityProcessing(Entity entity, Scope scope, int record)
          Deprecated. use retrievedEntityProcessing(Entity, Scope, int, Connection) instead.
protected  Entity retrievedEntityProcessing(Entity entity, Scope scope, int record, java.sql.Connection connection)
          Processes retrieved Entities before they are returned by retrieve(org.pajes.db.entity.Scope) or added to the set of Entities by retrieveSet(org.pajes.db.entity.Scope).
protected  Entity[] retrieveSet(java.sql.Connection connection, java.sql.ResultSet resultSet, Scope scope, int firstRecord, int setSize)
          Retrieves rows from the database table and converts them into Entity objects.
 Entity[] retrieveSet(Scope scope)
          Selects entities from the database table.
 Entity[] retrieveSet(Scope scope, int firstRecord, int setSize)
          Selects entities from the database table.
 Entity[] retrieveSet(Scope scope, int firstRecord, int setSize, java.sql.Connection connection)
          Selects entities from the database table.
 java.sql.ResultSet select(Scope scope, java.sql.Connection connection)
          Selects a ResultSet from the database table.
protected  void setCaching(Attributes column)
          Determines whether the Entity caching mechanism is enabled or not.
protected  void setEditor(java.lang.Class editor)
          Sets the Editor sub-class from which Editor instances can be created.
protected  void setEntity(java.lang.Class entity)
          Sets the class that from which a new instance will be returned when creating a new entity.
protected  void setLister(java.lang.Class lister)
          Sets the Lister sub-class from which Lister instances can be created.
 Manager setOrderByColumns(java.lang.String columns)
          Sets the default sort order when multiple entities are retrieved.
 Manager setTableName(java.lang.String table)
          Sets the name of the database table that this object manages.
protected  void setViewer(java.lang.Class viewer)
          Sets the Viewer sub-class from which Viewer instances can be created.
 java.lang.String toString()
          Returns a String representation of this Manager.
 int update(Entity entity)
          Updates an entity in the database table.
 int update(Entity entity, java.sql.Connection connection)
          Updates an entity in the database table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EDITOR_FACTORY

public static final java.lang.String EDITOR_FACTORY
Deprecated. Moved to DefaultEditor.EDITOR_FACTORY

The name of the ServletContext attribute that can contain a PajeFactory instance that will generate generic forms for displaying and editing Entity objects.

See Also:
Constant Field Values

LISTER_FACTORY

public static final java.lang.String LISTER_FACTORY
Deprecated. Moved to DefaultLister.LISTER_FACTORY

The name of the ServletContext attribute that can contain a PajeFactory instance that will generate generic lists to displaying Entity objects.

See Also:
Constant Field Values
Constructor Detail

Manager

public Manager(java.lang.Class entity,
               java.lang.String table,
               ConnectionManager manager)
Creates an Manager for managing the specified Entity objects.

Parameters:
entity - the Entity sub-class to be managed by this manager.
table - the name of the database table that this class manages.
manager - the ConnectionPoolManager that will provide the connection pool through which database access will occur.

Manager

public Manager(java.lang.Class entity,
               java.lang.String table,
               ConnectionPool pool)
Creates an Manager for managing the specified Entity objects.

Parameters:
entity - the Entity sub-class to be managed by this manager.
table - the name of the database table that this class manages.
pool - the connection pool through which database access will occur.
Method Detail

getAdminServletName

public java.lang.String getAdminServletName()
Returns the MaintenanceServlet class name that is used to administer the Entity objects managed by this class.

Returns:
The MaintenanceServlet class name, or null if MaintenanceServlet has been registered.

getAdminServletURI

public URI getAdminServletURI()
Returns the URI of the MaintenanceServlet that is used to administer the Entity objects managed by this class.

Returns:
The MaintenanceServlet URI, or null if MaintenanceServlet has been registered.

getAttributes

public java.util.HashMap getAttributes()
Returns the entity attributes as a HashMap, with the UPPER CASE column name as the key and the Attributes objects as the associated value.

Returns:
the entity attributes.

getColumnNames

public java.lang.String[] getColumnNames()
Returns the names of all the defined columns.

Returns:
the names of all the defined columns.

getConnectionPool

public ConnectionPool getConnectionPool()
Returns the connection pool from which a database connection may be requested.

Returns:
the connection pool.

getDBConnection

public java.sql.Connection getDBConnection()
                                    throws java.sql.SQLException
Convenience method to return a free connection from the connection pool.

Returns:
a database connection on which SQL Statements can be executed.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

getEditor

public Paje getEditor(javax.servlet.ServletContext context,
                      javax.servlet.http.HttpServletRequest request,
                      boolean isNew)
               throws EntityException,
                      java.io.IOException
Returns a Paje to display and/or edit an Entity object.

Parameters:
context - the ServletContext.
request - the request object.
isNew - true if the edit form is to be returned empty so that a new Entity may be defined, or false if an Entity is to be retrieved based on the request parameters, and then used to populate the form input fields.
Returns:
a new Paje object.
Throws:
EntityException - if an error occurs instantiating the Editor.
java.io.IOException - if an error occurs creating the Paje.
See Also:
DefaultEditor, setEditor(java.lang.Class)

getLister

public Paje getLister(javax.servlet.ServletContext context,
                      javax.servlet.http.HttpServletRequest request)
               throws EntityException,
                      java.io.IOException
Returns a Paje to display a list of Entity objects.

Parameters:
context - the ServletContext.
request - the request object.
Returns:
a new Paje object populated with the list of Entity objects.
Throws:
EntityException - if an error occurs instantiating the Lister.
java.io.IOException - if an error occurs creating the Paje.
See Also:
DefaultLister, setLister(java.lang.Class)

getOrderByClause

public java.lang.String getOrderByClause()
Returns the ORDER BY clause to sort the result set.

Returns:
the complete ORDER BY clause, or and empty String if no sort columns have been defined.
See Also:
setOrderByColumns(java.lang.String)

setOrderByColumns

public Manager setOrderByColumns(java.lang.String columns)
Sets the default sort order when multiple entities are retrieved. This may be over-ridden by Scope.setOrderByColumns(java.lang.String).

Parameters:
columns - the comma separated list of columns that will be used in the ORDER BY clause.
Returns:
the modified Manager object.

getPrimaryKeyValues

public java.lang.String getPrimaryKeyValues(Entity entity)
Returns a String that should uniquely identify the specified Entity.

Parameters:
entity - the Entity from which the key values will be extracted.
Returns:
a String that should uniquely identify the specified Entity.

getPrimaryKeyValues

public java.lang.String getPrimaryKeyValues(javax.servlet.http.HttpServletRequest request)
Returns a String that should uniquely identify an Entity.

Parameters:
request - the servlet request containing the values.
Returns:
a String that should uniquely identify an Entity.

getPrimaryKeys

public java.lang.String[] getPrimaryKeys()
Returns the names of the defined primary keys, or if no primary keys have been defined, the names of all columns.

Returns:
the names of the columns that will uniquely identify a single Entity.

setTableName

public Manager setTableName(java.lang.String table)
Sets the name of the database table that this object manages.

Parameters:
table - the name of the database table.
Returns:
the modified Manager object.

getTableName

public java.lang.String getTableName()
Retrieves the name of the database table that this object manages.

Returns:
the name of the database table.

getViewer

public Paje getViewer(javax.servlet.ServletContext context,
                      javax.servlet.http.HttpServletRequest request)
               throws EntityException,
                      java.io.IOException
Returns a Paje to display an Entity object.

Parameters:
context - the ServletContext.
request - the request object.
Returns:
a new Paje object.
Throws:
EntityException - if an error occurs instantiating the Editor.
java.io.IOException - if an error occurs creating the Paje.
See Also:
DefaultEditor, setEditor(java.lang.Class)

create

public Entity create()
Creates a new Entity instance.

Sub-classes may over-ride this method to do any Entity-specific initialisation, such as the assigning of default values. In this case, the sub-class must call super.create() before anythig else.

Returns:
a new Entity of the appropriate Entity sub-class.

delete

public int delete(Entity entity)
           throws java.sql.SQLException
Deletes an entity from the database table.

Parameters:
entity - the Entity object to be deleted from the table.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

delete

public int delete(Entity entity,
                  java.sql.Connection connection)
           throws java.sql.SQLException
Deletes an entity from the database table.

Parameters:
entity - the Entity object to be deleted from the table.
connection - the connection on which the statement is to be executed.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

delete

public int delete(Scope scope)
           throws java.sql.SQLException
Delete entities that match the specified Scope from the table.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

delete

public int delete(Scope scope,
                  java.sql.Connection connection)
           throws java.sql.SQLException
Delete entities that match the specified Scope from the table.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
connection - the connection on which the statement is to be executed.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

insert

public int insert(Entity entity)
           throws java.sql.SQLException
Inserts an entity into the database table.

Parameters:
entity - the Entity object to be inserted into the table.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

insert

public int insert(Entity entity,
                  java.sql.Connection connection)
           throws java.sql.SQLException
Inserts an entity into the database table.

Parameters:
entity - the Entity object to be inserted into the table.
connection - the connection on which the statement is to be executed.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

recache

public void recache()
             throws java.sql.SQLException
Refreshes the local cache, it one exists.

Throws:
java.sql.SQLException - if any errors occur processing the request.

retrieve

public Entity retrieve(Scope scope)
                throws EntityNotFoundException,
                       java.sql.SQLException
Retrieves a single entity.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
Returns:
the first entity that meets the scope criteria.
Throws:
EntityNotFoundException
java.sql.SQLException - if any errors occur processing the request.

retrieve

public Entity retrieve(Scope scope,
                       int record)
                throws EntityNotFoundException,
                       java.sql.SQLException
Retrieves a single entity.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
record - the record number within the scope to retrieve. Use -1 to retrieve the last record in the set.
Returns:
the specified entity that meets the scope criteria.
Throws:
EntityNotFoundException - if the Entity requested by the Scope does not exist.
java.sql.SQLException - if any errors occur processing the request.

retrieve

public Entity retrieve(Scope scope,
                       int record,
                       java.sql.Connection connection)
                throws EntityNotFoundException,
                       java.sql.SQLException
Retrieves a single entity.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
record - the record number within the scope to retrieve. Use -1 to retrieve the last record in the set.
connection - the connection on which the query is to be performed.
Returns:
the specified entity that meets the scope criteria.
Throws:
EntityNotFoundException - if the Entity requested by the Scope does not exist.
java.sql.SQLException - if any errors occur processing the request.

retrieveCount

public int retrieveCount(Scope scope)
                  throws java.sql.SQLException
Retrieves the count of Entities that meet the scope criteria.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
Returns:
the number of entities.
Throws:
java.sql.SQLException - if any errors occur processing the request.

retrieveCount

public int retrieveCount(Scope scope,
                         java.sql.Connection connection)
                  throws java.sql.SQLException
Retrieves the count of Entities that meet the scope criteria.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
connection - the connection on which the query is to be performed.
Returns:
the number of entities.
Throws:
java.sql.SQLException - if any errors occur processing the request.

retrieveSet

public Entity[] retrieveSet(Scope scope)
                     throws java.sql.SQLException
Selects entities from the database table.

Parameters:
scope - an object that determines the scope of the entities that will be retrieved.
Returns:
an array of Entity instances selected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

retrieveSet

public Entity[] retrieveSet(Scope scope,
                            int firstRecord,
                            int setSize)
                     throws java.sql.SQLException
Selects entities from the database table.

Parameters:
scope - an object that determines the scope of the entities that will be retrieved.
firstRecord - the first record number to retrieve. Use -1 to retrieve the last row of the set.
setSize - the maximum number of rows to return. Use -1 to return all rows in the set.
Returns:
an array of Entity instances selected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

retrieveSet

public Entity[] retrieveSet(Scope scope,
                            int firstRecord,
                            int setSize,
                            java.sql.Connection connection)
                     throws java.sql.SQLException
Selects entities from the database table.

Parameters:
scope - an object that determines the scope of the entities that will be retrieved.
firstRecord - the first record number to retrieve. Use -1 to retrieve the last row of the set.
setSize - the maximum number of rows to return. Use -1 to return all rows in the set.
connection - the connection on which the query is to be performed.
Returns:
an array of Entity instances selected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

select

public java.sql.ResultSet select(Scope scope,
                                 java.sql.Connection connection)
                          throws java.sql.SQLException
Selects a ResultSet from the database table.

NOTE: If you elect to use this method, you MUST manually call ResultSet.getStatement().close() when you finished processing the returned result set!

Parameters:
scope - an object that determines the scope of the entities that will be retrieved.
connection - the connection on which the query is to be performed.
Returns:
the ResultSet.
Throws:
java.sql.SQLException - if any errors occur processing the request.

toString

public java.lang.String toString()
Returns a String representation of this Manager.

Returns:
this Manager as a String.

update

public int update(Entity entity)
           throws java.sql.SQLException
Updates an entity in the database table.

Parameters:
entity - the Entity object to be updated in the table.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

update

public int update(Entity entity,
                  java.sql.Connection connection)
           throws java.sql.SQLException
Updates an entity in the database table.

Parameters:
entity - the Entity object to be updated in the table.
connection - the connection on which the statement is to be executed.
Returns:
the number of rows affected.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

makePrimaryKeyString

protected static java.lang.String makePrimaryKeyString(java.lang.Class entity,
                                                       java.lang.String[] keys,
                                                       java.lang.Object[] values)
Returns a String that should uniquely identify an Entity.

Parameters:
entity - the Entity class.
keys - the array of primary key names.
values - the array of primary key values.
Returns:
a String that should uniquely identify an Entity.

setCaching

protected void setCaching(Attributes column)
                   throws java.sql.SQLException
Determines whether the Entity caching mechanism is enabled or not. Enabling caching creates the cache.

Note: caching is extemely simplistic, and is only suitable for very small reference tables. Caching should only be enabled from within the constructor.

Parameters:
column - the single column on which items may be retrieved from the cache. If null, caching is disabled.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

getColumnPosition

protected int getColumnPosition(java.lang.Class defaultClass,
                                Attributes attributes)
Called when an Attributes object is registered with the Manager to determine the default location of the column in the DefaultEditor, DefaultLister and DefaultViewer. This method is only called if the position returned by the Attributes object is 0.

The default implementation returns a sequential number, starting with 0, for each column registered.

Parameters:
defaultClass - one of DefaultEditor.class, DefaultLister.class or DefaultViewer.class.
attributes - The Attributes being registered.
Returns:
the position.

setEditor

protected void setEditor(java.lang.Class editor)
                  throws java.lang.ClassCastException,
                         java.lang.IllegalAccessException,
                         java.lang.InstantiationException
Sets the Editor sub-class from which Editor instances can be created.

Parameters:
editor - the Editor class.
Throws:
java.lang.ClassCastException - if the specified class is not a subclass of Editor.
java.lang.IllegalAccessException - if this class does not have access to instantiate the Editor
java.lang.InstantiationException - if the class specified is an interfacce or an abstract class.
See Also:
DefaultEditor

setEntity

protected void setEntity(java.lang.Class entity)
Sets the class that from which a new instance will be returned when creating a new entity.

Parameters:
entity - the Class from which new Entity instance will be generated.

getEntity

protected java.lang.Class getEntity()
Retuuns the class from which a new instance will be returned when creating a new entity.

Returns:
the Class from which new Entity instance will be generated.

setLister

protected void setLister(java.lang.Class lister)
                  throws java.lang.ClassCastException,
                         java.lang.IllegalAccessException,
                         java.lang.InstantiationException
Sets the Lister sub-class from which Lister instances can be created.

Parameters:
lister - the Lister class.
Throws:
java.lang.ClassCastException - if the specified class is not a subclass of Lister.
java.lang.IllegalAccessException - if this class does not have access to instantiate the Lister
java.lang.InstantiationException - if the class specified is an interfacce or an abstract class.
See Also:
DefaultLister

getSQLDeleteStatement

protected java.sql.PreparedStatement getSQLDeleteStatement(Entity entity,
                                                           java.sql.Connection connection)
                                                    throws java.sql.SQLException
Returns the SQL PreparedStatement string that will deletes the specified entity from the table.

Parameters:
entity - the Entity object to be deleted from the table.
connection - the database connection on which the SQL will be executed.
Returns:
the PreparedStatement that will handle the request.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

getSQLDeleteStatement

protected java.sql.PreparedStatement getSQLDeleteStatement(Scope scope,
                                                           java.sql.Connection connection)
                                                    throws java.sql.SQLException
Returns the SQL PreparedStatement string that will delete entities that match the specified Scope from the table.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
connection - the database connection on which the SQL will be executed.
Returns:
the PreparedStatement that will handle the request.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

getSQLInsertStatement

protected java.sql.PreparedStatement getSQLInsertStatement(Entity entity,
                                                           java.sql.Connection connection)
                                                    throws java.sql.SQLException
Returns the SQL PreparedStatement string that will inserts the specified entity into the table.

Parameters:
entity - the Entity object to be inserted into the table.
connection - the database connection on which the SQL will be executed.
Returns:
the PreparedStatement that will handle the request.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

getSQLSelectStatement

protected java.sql.PreparedStatement getSQLSelectStatement(Scope scope,
                                                           java.sql.Connection connection)
                                                    throws java.sql.SQLException
Returns the SQL PreparedStatement string that will select entities that match the specified Scope from the table.

Parameters:
scope - an object that determines the scope of the entities that will be affected by this action.
connection - the database connection on which the SQL will be executed.
Returns:
the PreparedStatement that will handle the request.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

getSQLUpdateStatement

protected java.sql.PreparedStatement getSQLUpdateStatement(Entity entity,
                                                           java.sql.Connection connection)
                                                    throws java.sql.SQLException
Returns the SQL PreparedStatement string that will updates the specified entity in the table.

Parameters:
entity - the Entity object to be updated in the table.
connection - the database connection on which the SQL will be executed.
Returns:
the PreparedStatement that will handle the request, or null if no vlaues have been changed.
Throws:
java.sql.SQLException - if an error occurs accessing the database.

setViewer

protected void setViewer(java.lang.Class viewer)
                  throws java.lang.ClassCastException,
                         java.lang.IllegalAccessException,
                         java.lang.InstantiationException
Sets the Viewer sub-class from which Viewer instances can be created.

Parameters:
viewer - the Viewer class.
Throws:
java.lang.ClassCastException - if the specified class is not a subclass of Viewer.
java.lang.IllegalAccessException - if this class does not have access to instantiate the Viewer
java.lang.InstantiationException - if the class specified is an interfacce or an abstract class.
See Also:
DefaultViewer

onCacheEntity

protected void onCacheEntity(Entity entity)
Called immediately after an individual entity is cached. The default implementation does nothing.

Sub-classes may over-ride this method to perform any Manager specific processing.

Parameters:
entity - the Entity being cached.

onCacheRefresh

protected void onCacheRefresh(java.sql.Connection connection)
                       throws java.sql.SQLException
Called immediately after a cache refresh. The default implementation does nothing.

Sub-classes may over-ride this method to perform any Manager specific processing.

Parameters:
connection - the connection on which the cache was refreshed.
Throws:
java.sql.SQLException - if a database exception occurs.

retrieveSet

protected Entity[] retrieveSet(java.sql.Connection connection,
                               java.sql.ResultSet resultSet,
                               Scope scope,
                               int firstRecord,
                               int setSize)
                        throws java.sql.SQLException
Retrieves rows from the database table and converts them into Entity objects.

Parameters:
connection - the connection on which the result set was obtained.
resultSet - the result set containing the rows to be converted into Entity objects.
scope - an object that determines the scope of the entities that were retrieved.
firstRecord - the first record number to retrieve. Use -1 to retrieve the last row of the set.
setSize - the maximum number of rows to return. Use -1 to return all rows in the set.
Returns:
an array of Entity instances selected.
Throws:
java.sql.SQLException - if any errors occur processing the request.

retrievedEntityProcessing

protected Entity retrievedEntityProcessing(Entity entity,
                                           Scope scope,
                                           int record)
                                    throws java.sql.SQLException
Deprecated. use retrievedEntityProcessing(Entity, Scope, int, Connection) instead.

Deprecated.

Parameters:
entity - the Entity to be returned to the request.
scope - an object that determines the scope of the Entities that were requested.
record - the ordinal position of this Entity in the set.
Returns:
the modified Entity.
Throws:
java.sql.SQLException - if any errors occur processing the request.

retrievedEntityProcessing

protected Entity retrievedEntityProcessing(Entity entity,
                                           Scope scope,
                                           int record,
                                           java.sql.Connection connection)
                                    throws java.sql.SQLException
Processes retrieved Entities before they are returned by retrieve(org.pajes.db.entity.Scope) or added to the set of Entities by retrieveSet(org.pajes.db.entity.Scope).

Allows sub-classes to modify the Entity prior to it being returned.

The default implementation does nothing except return the Entity passed as a parameter.

Parameters:
entity - the Entity to be returned to the request.
scope - an object that determines the scope of the Entities that were requested.
record - the ordinal position of this Entity in the set.
connection - the connection on whicht the Entity was retrieved.
Returns:
the modified Entity.
Throws:
java.sql.SQLException - if any errors occur processing the request.

PAJES 2.3.9

Copyright © 2002-2003 Viridian Pty Limited. All Rights Reserved.