bill.util.persist
Class EntityDataRDBMS

java.lang.Object
  |
  +--bill.util.persist.EntityData
        |
        +--bill.util.persist.EntityDataRDBMS

public abstract class EntityDataRDBMS
extends EntityData

This class is used to define an entity and to manipulate the entity in the persistent store. This class works with a RDBMS, in which case an entity represents a row in a table.


Fields inherited from class bill.util.persist.EntityData
_collectionInfo, _collections, _elements, _entityName, _keys, _state, ET_BOOLEAN, ET_DOUBLE, ET_INTEGER, ET_LONG, ET_OID, ET_REAL, ET_STRING
 
Constructor Summary
EntityDataRDBMS()
          Creator based on the name of the entity.
EntityDataRDBMS(String entityName)
          Creator based on the name of the entity.
EntityDataRDBMS(String entityName, Hashtable keyValues)
          Creator based on the name of the entity and the key elements' values.
 
Method Summary
protected  String createDeleteSQL()
          Creates the SQL needed to delete an existing entity from the persistent data store.
protected  String createInsertSQL()
          Creates the SQL needed to add a new entity to the persistent data store.
protected  String createSelectSQL()
          Creates the SQL needed to select some existing entities in the persistent data store.
protected  String createSelectSQL(Hashtable keyValues)
          Creates the SQL needed to select an existing entity (or entities) in the persistent data store.
protected  String createUpdateSQL()
          Creates the SQL needed to update an existing entity in the persistent data store.
 String getCollectionClassName()
          Returns the class name of the EntityCollection class associated with this class.
 void retrieve(Hashtable keyValues)
          Retrieves an entity from the database that is keyed by the given key values.
 int save()
          Controls the updating of the persistent store with the entity's information.
 
Methods inherited from class bill.util.persist.EntityData
addElement, containsElement, getCollection, getElement, getElements, getElementValue, getEntityName, getKey, identifyElements, identifyKeyElement, identifyRequiredElement, instantiateCollection, isDeleted, isModified, isNew, registerOneToManyCollection, setClean, setDeleted, setElementValue, setElementValues, setEntityName, setModified, setNew, toString, userValidate, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EntityDataRDBMS

public EntityDataRDBMS()
Creator based on the name of the entity. Populates and defaults class instance variables. The user must call setEntityName before being able to do much with an object created with this creator.

EntityDataRDBMS

public EntityDataRDBMS(String entityName)
Creator based on the name of the entity. Populates and defaults class instance variables.
Parameters:
entityName - The name of the entity.

EntityDataRDBMS

public EntityDataRDBMS(String entityName,
                       Hashtable keyValues)
                throws PersistException
Creator based on the name of the entity and the key elements' values. Populates and defaults class instance variables, the populates the entity's element values from the persistent data store.
Parameters:
entityName - The name of the entity.
keyValues - The key element's values. Keyed by the element's logical name, result is the element's value.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the retrieval. In our case this would be a SQLException of some sort.
Method Detail

getCollectionClassName

public String getCollectionClassName()
Returns the class name of the EntityCollection class associated with this class.
Overrides:
getCollectionClassName in class EntityData
Returns:
The full package name of the collection class, in this case bill.util.EntityCollectionRDBMS.

createInsertSQL

protected String createInsertSQL()
Creates the SQL needed to add a new entity to the persistent data store. This is done by looping through all the registered elements and their values and building the SQL string using these values.
Returns:
The SQL string to perform the insert.

createUpdateSQL

protected String createUpdateSQL()
                          throws PersistException
Creates the SQL needed to update an existing entity in the persistent data store. This is done by looping through all the registered elements and their values and building the SQL string using these values.
Returns:
The SQL string to perform the update.

createDeleteSQL

protected String createDeleteSQL()
                          throws PersistException
Creates the SQL needed to delete an existing entity from the persistent data store. This is done by looping through all the registered elements and their values and building the SQL string using these values.
Returns:
The SQL string to perform the delete.

createSelectSQL

protected String createSelectSQL()
                          throws PersistException
Creates the SQL needed to select some existing entities in the persistent data store.
Returns:
The SQL string to perform the select.

createSelectSQL

protected String createSelectSQL(Hashtable keyValues)
                          throws PersistException
Creates the SQL needed to select an existing entity (or entities) in the persistent data store. This is done by looping through all the specified elements and their values and building the SQL string using these values.
Parameters:
keyValues - The key element's values. Keyed by the element's logical name, result is the element's value.
Returns:
The SQL string to perform the select.

save

public int save()
         throws PersistException
Controls the updating of the persistent store with the entity's information. Determines the type of action to perform against the store (insert, update, or delete) and calls the appropriate method to build the SQL statement to perform the action, then executes the SQL statement.
Overrides:
save in class EntityData
Returns:
The number of rows affected by the persistent store update.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the action. In our case this would be a SQLException of some sort or a validation error.

retrieve

public void retrieve(Hashtable keyValues)
              throws PersistException
Retrieves an entity from the database that is keyed by the given key values.
Overrides:
retrieve in class EntityData
Parameters:
keyValues - The key element's values. Keyed by the element's logical name, result is the element's value.
Throws:
PersistException - If a fatal error occurs that causes us to not be able to perform the retrieval. In our case this would be a SQLException of some sort.