|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.jcorporate.expresso.core.dataobjects.jdbc.JDBCExecutor
Initial separation of DBObjects from the underlying JDBC code that gets executed. This is part number 1 where we move a lot of the JDBC code over to this helper class. For round #1 iteration, we're assuming that the valueObject is actually a DBObject that implements the DataObject interface (which it does). This is because we're interested in getting something working and demonstratable, and then slowly flesh out the DataObject interface so that we can eventually completely prune this class completely away from the DBObject class and work strictly with the DataObject Interface.
| Field Summary | |
static int |
LONGBINARY_READ_DEFAULT_SIZE
|
static String |
LONGVARBINARY_TYPE
|
static String |
LONGVARCHAR_TYPE
|
static String |
VARBINARY_TYPE
|
| Constructor Summary | |
JDBCExecutor()
|
|
| Method Summary | |
void |
add(DataObject valueObject)
Takes a DataObject and adds it to the underlying data source |
void |
addBatch(List valueObjectList)
Adds an entire batch of DataObjects to the underlying JDBC data source |
void |
addBatch(List valueObjectList,
boolean addChangedFieldsOnly)
Adds an entire batch of DataObjects to the underlying JDBC data source |
protected String |
buildPreparedAddSQL(DataObject oneObjectType,
boolean addChangedFieldsOnly)
Helper Function to build a prepared statement's SQL for an ADD statement. |
protected String |
buildPreparedDeleteSQL(DataObject oneObjectType,
boolean deleteWithSetFieldsOnly)
Helper function to build a prepared delete statement for batch deletes. |
protected String |
buildPreparedStoreProcedureSQL(DataObject oneObjectType)
Helper Function to build a prepared statement's SQL for running STore Procedure statement. |
protected String |
buildPreparedUpdateSQL(DataObject oneObjectType,
boolean updateChangedFieldsOnly)
Helper function to build a prepared update statement for batch updates. |
protected void |
buildStoreProcedureCallableStatement(DBObject criteria,
CallableStatement myCallableStatement)
Build and return a FastStringBuffer ring consisting of an SQL 'where' clause using the current field values as criteria for the search. |
void |
delete(DataObject valueObject)
Takes a DataObject and deletes it from the underlying data source.
|
void |
deleteAll(DataObject valueObject,
boolean deleteChangedCache)
Takes a DataObject and deletes it from the underlying data source.
|
void |
deleteBatch(List valueObjectList)
Deletes an entire batch of DataObjects |
void |
deleteBatch(List valueObjectList,
boolean deleteWithSetFieldsOnly)
Updates an entire batch of DataObjects |
protected String |
prepareForStorage(DataFieldMetaData oneField,
DBObject theObj)
Format the field for storage into a prepared statement. |
protected String |
prepareForStorage(DataFieldMetaData oneField,
DBObject theObj,
boolean dateFormatted)
Format the field for storage into a prepared statement. |
boolean |
retrieve(DataObject valueObject)
Retrieves the object with keys specified by the valueObject parameter. |
void |
runStoreProcedure(DataObject valueObject)
Run a store procedure identify by the object with keys specified by the valueObject parameter. |
void |
update(DataObject valueObject,
boolean updateChangedFieldsOnly)
Takes a DataObject and updates it to the underlying data source |
void |
updateAll(DataObject valueObject,
boolean updateChangedCache)
Takes a DataObject and updates all to the underlying data source |
void |
updateBatch(List valueObjectList)
Updates an entire batch of DataObjects |
void |
updateBatch(List valueObjectList,
boolean updateChangedFieldsOnly)
Updates an entire batch of DataObjects |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final transient String LONGVARBINARY_TYPE
public static final transient String VARBINARY_TYPE
public static final transient String LONGVARCHAR_TYPE
public static int LONGBINARY_READ_DEFAULT_SIZE
| Constructor Detail |
public JDBCExecutor()
| Method Detail |
public void add(DataObject valueObject)
throws DataException,
DuplicateKeyException
DataObject and adds it to the underlying data source
add in interface DataExecutorInterfacevalueObject - the DataObject to add.
DataException - upon error adding the object to the data source
DuplicateKeyException - if the object already existed in the data
source.
Modify by Yves Henri AMAIZO
public void delete(DataObject valueObject)
throws DataException
DataObject and deletes it from the underlying data source.
Note: The current implementation only expects a DBObject
and actually routes the call back to that object. Will be fixed in the future
as the interface becomes more rich.
delete in interface DataExecutorInterfacevalueObject - the DataObject to delete.
DataException - upon error deleting the object to the data source
public void update(DataObject valueObject,
boolean updateChangedFieldsOnly)
throws DataException
DataObject and updates it to the underlying data source
update in interface DataExecutorInterfacevalueObject - the DataObject to update.updateChangedFieldsOnly - if true only modified fields (isChanged = true)
will be included in the update
DataException - upon error updating the object to the data source
Modify by Yves Henri AMAIZO
public boolean retrieve(DataObject valueObject)
throws DataException
DBObject's retrieve method.
retrieve in interface DataExecutorInterfacevalueObject - the DataObject who's keys are already set to retrieve
DataException - Modify by Yves Henri AMAIZO
public void addBatch(List valueObjectList)
throws DataException,
DuplicateKeyException
DataObjects to the underlying JDBC data source
addBatch in interface DataExecutorInterfacevalueObjectList - A list of DataObjects to add to the underlying
data source NOTE: you will get best performance if valueObjectList is
all one dataobject underneath.
WARNING: I DON'T UNDERSTAND WHY LOOP VAR ISN'T USED BELOW, AND SUSPECT THIS METHOD ISN'T DOING ALL IT PURPORTS TO DO; SEE "todo" (Larry Hamel, 3/03)
DataException - upon error communicating with the underlying data source
DuplicateKeyException - if one of the records was already in the
data source
public void updateBatch(List valueObjectList)
throws DataException
DataObjects
updateBatch in interface DataExecutorInterfacevalueObjectList - A list of DataObjects to update to the underlying
data source
DataException - upon error updating the data source
protected String buildPreparedUpdateSQL(DataObject oneObjectType,
boolean updateChangedFieldsOnly)
throws DBException
oneObjectType - A single DataObject that is used to model the prepared
statement. Only metadata about the DataObject is used.updateChangedFieldsOnly - true if the changed fields should be the
only ones sent through the SQL query.
FastStringBuffer containing the proper SQL to create
a preparedStatement
DBException - upon error
Modify by Yves Henri AMAIZO
protected String buildPreparedDeleteSQL(DataObject oneObjectType,
boolean deleteWithSetFieldsOnly)
throws DBException
oneObjectType - A single DataObject that is used to model the prepared
statement. Only metadata about the DataObject is used.
FastStringBuffer containing the proper SQL to create
a preparedStatement
DBException - upon error
Modify by Yves Henri AMAIZO
protected String buildPreparedAddSQL(DataObject oneObjectType,
boolean addChangedFieldsOnly)
throws DBException
oneObjectType - A single DataObject that is used to model the prepared
statement. Only metadata about the DataObject is used.addChangedFieldsOnly - flag to signify if only fields whose value
has changed should be included in the add.
DBException - upon error
Modify by Yves Henri AMAIZO
protected String prepareForStorage(DataFieldMetaData oneField,
DBObject theObj)
throws DBException
DBObject.quoteIfNeeded() but it does not insert
quotes around the values since the prepared statements will take care
of special characters like that
oneField - The metadata of the field to retrievetheObj - The DBObject that contains the data to store.
DBException
protected String prepareForStorage(DataFieldMetaData oneField,
DBObject theObj,
boolean dateFormatted)
throws DBException
DBObject.quoteIfNeeded() but it does not insert
quotes around the values since the prepared statements will take care
of special characters like that
oneField - The metadata of the field to retrievetheObj - The DBObject that contains the data to store.
DBException
public void updateAll(DataObject valueObject,
boolean updateChangedCache)
throws DataException
DataObject and updates all to the underlying data source
updateAll in interface DataExecutorInterfacevalueObject - the DataObject to update.updateChangedCache - if true only modified fields (isChanged = true)
will be included in the update
DataException - upon error updating the object to the data source
Modify by Yves Henri AMAIZO
public void deleteAll(DataObject valueObject,
boolean deleteChangedCache)
throws DataException
DataObject and deletes it from the underlying data source.
Note: The current implementation only expects a DBObject
and actually routes the call back to that object. Will be fixed in the future
as the interface becomes more rich.
deleteAll in interface DataExecutorInterfacevalueObject - the DataObject to delete.
DataException - upon error deleting the object to the data source
protected String buildPreparedStoreProcedureSQL(DataObject oneObjectType)
throws DBException
oneObjectType - A single DataObject that is used to model the prepared
statement. Only metadata about the DataObject is used.
DBException - upon error
protected void buildStoreProcedureCallableStatement(DBObject criteria,
CallableStatement myCallableStatement)
throws DataException
criteria - the JDBCDataObject to build frommyCallableStatement - the statement
DataException - upon error
public void runStoreProcedure(DataObject valueObject)
throws DataException
runStoreProcedure in interface DataExecutorInterfacevalueObject - the DataObject who's keys are already set to retrieve
DataException - upon error retriving the object from the data source
public void addBatch(List valueObjectList,
boolean addChangedFieldsOnly)
throws DataException,
DuplicateKeyException
DataObjects to the underlying JDBC data source
valueObjectList - A list of DataObjects to add to the underlying
data source NOTE: you will get best performance if valueObjectList is
all one dataobject underneath.addChangedFieldsOnly - flag to signify if only fields whose value
has changed should be included in the add.
WARNING: I DON'T UNDERSTAND WHY LOOP VAR ISN'T USED BELOW, AND SUSPECT THIS METHOD ISN'T DOING ALL IT PURPORTS TO DO; SEE "todo" (Larry Hamel, 3/03)
DataException - upon error communicating with the underlying data source
DuplicateKeyException - if one of the records was already in the
data source
public void updateBatch(List valueObjectList,
boolean updateChangedFieldsOnly)
throws DataException
DataObjects
updateBatch in interface DataExecutorInterfacevalueObjectList - A list of DataObjects to update to the underlying
data sourceupdateChangedFieldsOnly - flag to signify if only fields whose value
has changed should be included in the update.
DataException - upon error updating the data source
public void deleteBatch(List valueObjectList,
boolean deleteWithSetFieldsOnly)
throws DataException
DataObjects
deleteBatch in interface DataExecutorInterfacevalueObjectList - A list of DataObjects to update to the underlying
data sourcedeleteWithSetFieldsOnly - Only include changed fields in the update
DataException - upon error updating the data source
public void deleteBatch(List valueObjectList)
throws DataException
DataObjects
deleteBatch in interface DataExecutorInterfacevalueObjectList - A list of DataObjects to delete to the underlying
data source
DataException - upon error deleting the data source
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||