Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.jcorporate.expresso.core.dataobjects.jdbc
Class JDBCExecutor  view JDBCExecutor download JDBCExecutor.java

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCExecutor
All Implemented Interfaces:
com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

public class JDBCExecutor
extends java.lang.Object
implements com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

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.

Since:
Expresso 5.0

Field Summary
private static org.apache.log4j.Logger log
           
static int LONGBINARY_READ_DEFAULT_SIZE
           
static java.lang.String LONGVARBINARY_TYPE
           
static java.lang.String LONGVARCHAR_TYPE
           
private static java.lang.String myName
           
static java.lang.String VARBINARY_TYPE
           
 
Constructor Summary
JDBCExecutor()
           
 
Method Summary
 void add(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
          Takes a DataObject and adds it to the underlying data source
 void addBatch(java.util.List valueObjectList)
          Adds an entire batch of DataObjects to the underlying JDBC data source
 void addBatch(java.util.List valueObjectList, boolean addChangedFieldsOnly)
          Adds an entire batch of DataObjects to the underlying JDBC data source
protected  java.lang.String buildPreparedAddSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType, boolean addChangedFieldsOnly)
          Helper Function to build a prepared statement's SQL for an ADD statement.
protected  java.lang.String buildPreparedDeleteSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType, boolean deleteWithSetFieldsOnly)
          Helper function to build a prepared delete statement for batch deletes.
protected  java.lang.String buildPreparedStoreProcedureSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType)
          Helper Function to build a prepared statement's SQL for running STore Procedure statement.
protected  java.lang.String buildPreparedUpdateSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType, boolean updateChangedFieldsOnly)
          Helper function to build a prepared update statement for batch updates.
protected  void buildStoreProcedureCallableStatement(com.jcorporate.expresso.core.dbobj.DBObject criteria, java.sql.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(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
          Takes a DataObject and deletes it from the underlying data source.
 void deleteAll(com.jcorporate.expresso.core.dataobjects.DataObject valueObject, boolean deleteChangedCache)
          Takes a DataObject and deletes it from the underlying data source.
 void deleteBatch(java.util.List valueObjectList)
          Deletes an entire batch of DataObjects
 void deleteBatch(java.util.List valueObjectList, boolean deleteWithSetFieldsOnly)
          Updates an entire batch of DataObjects
private  boolean haveAllKeysExceptAutoInc(com.jcorporate.expresso.core.dbobj.DBObject valueObject)
           
protected  java.lang.String prepareForStorage(com.jcorporate.expresso.core.dataobjects.DataFieldMetaData oneField, com.jcorporate.expresso.core.dbobj.DBObject theObj)
          Format the field for storage into a prepared statement.
protected  java.lang.String prepareForStorage(com.jcorporate.expresso.core.dataobjects.DataFieldMetaData oneField, com.jcorporate.expresso.core.dbobj.DBObject theObj, boolean dateFormatted)
          Format the field for storage into a prepared statement.
 boolean retrieve(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
          Retrieves the object with keys specified by the valueObject parameter.
 void runStoreProcedure(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
          Run a store procedure identify by the object with keys specified by the valueObject parameter.
 void update(com.jcorporate.expresso.core.dataobjects.DataObject valueObject, boolean updateChangedFieldsOnly)
          Takes a DataObject and updates it to the underlying data source
 void updateAll(com.jcorporate.expresso.core.dataobjects.DataObject valueObject, boolean updateChangedCache)
          Takes a DataObject and updates all to the underlying data source
 void updateBatch(java.util.List valueObjectList)
          Updates an entire batch of DataObjects
 void updateBatch(java.util.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

myName

private static final java.lang.String myName

log

private static org.apache.log4j.Logger log

LONGVARBINARY_TYPE

public static final transient java.lang.String LONGVARBINARY_TYPE
See Also:
Constant Field Values

VARBINARY_TYPE

public static final transient java.lang.String VARBINARY_TYPE
See Also:
Constant Field Values

LONGVARCHAR_TYPE

public static final transient java.lang.String LONGVARCHAR_TYPE
See Also:
Constant Field Values

LONGBINARY_READ_DEFAULT_SIZE

public static int LONGBINARY_READ_DEFAULT_SIZE
Constructor Detail

JDBCExecutor

public JDBCExecutor()
Method Detail

add

public void add(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
         throws com.jcorporate.expresso.core.dataobjects.DataException,
                com.jcorporate.expresso.core.dataobjects.DuplicateKeyException
Takes a DataObject and adds it to the underlying data source

Specified by:
add in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface
Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

delete

public void delete(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
            throws com.jcorporate.expresso.core.dataobjects.DataException
Takes a 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.

Specified by:
delete in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

update

public void update(com.jcorporate.expresso.core.dataobjects.DataObject valueObject,
                   boolean updateChangedFieldsOnly)
            throws com.jcorporate.expresso.core.dataobjects.DataException
Takes a DataObject and updates it to the underlying data source

Specified by:
update in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface
Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

retrieve

public boolean retrieve(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Retrieves the object with keys specified by the valueObject parameter. This has the same semantics as DBObject's retrieve method.

Specified by:
retrieve in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface
Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

addBatch

public void addBatch(java.util.List valueObjectList)
              throws com.jcorporate.expresso.core.dataobjects.DataException,
                     com.jcorporate.expresso.core.dataobjects.DuplicateKeyException
Adds an entire batch of DataObjects to the underlying JDBC data source

Specified by:
addBatch in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

updateBatch

public void updateBatch(java.util.List valueObjectList)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Updates an entire batch of DataObjects

Specified by:
updateBatch in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

buildPreparedUpdateSQL

protected java.lang.String buildPreparedUpdateSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType,
                                                  boolean updateChangedFieldsOnly)
                                           throws com.jcorporate.expresso.core.db.DBException
Helper function to build a prepared update statement for batch updates.

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

buildPreparedDeleteSQL

protected java.lang.String buildPreparedDeleteSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType,
                                                  boolean deleteWithSetFieldsOnly)
                                           throws com.jcorporate.expresso.core.db.DBException
Helper function to build a prepared delete statement for batch deletes.

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

buildPreparedAddSQL

protected java.lang.String buildPreparedAddSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType,
                                               boolean addChangedFieldsOnly)
                                        throws com.jcorporate.expresso.core.db.DBException
Helper Function to build a prepared statement's SQL for an ADD statement.

Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

prepareForStorage

protected java.lang.String prepareForStorage(com.jcorporate.expresso.core.dataobjects.DataFieldMetaData oneField,
                                             com.jcorporate.expresso.core.dbobj.DBObject theObj)
                                      throws com.jcorporate.expresso.core.db.DBException
Format the field for storage into a prepared statement. This is similar to the old DBObject.quoteIfNeeded() but it does not insert quotes around the values since the prepared statements will take care of special characters like that


prepareForStorage

protected java.lang.String prepareForStorage(com.jcorporate.expresso.core.dataobjects.DataFieldMetaData oneField,
                                             com.jcorporate.expresso.core.dbobj.DBObject theObj,
                                             boolean dateFormatted)
                                      throws com.jcorporate.expresso.core.db.DBException
Format the field for storage into a prepared statement. This is similar to the old DBObject.quoteIfNeeded() but it does not insert quotes around the values since the prepared statements will take care of special characters like that


haveAllKeysExceptAutoInc

private boolean haveAllKeysExceptAutoInc(com.jcorporate.expresso.core.dbobj.DBObject valueObject)
                                  throws com.jcorporate.expresso.core.db.DBException

updateAll

public void updateAll(com.jcorporate.expresso.core.dataobjects.DataObject valueObject,
                      boolean updateChangedCache)
               throws com.jcorporate.expresso.core.dataobjects.DataException
Takes a DataObject and updates all to the underlying data source

Specified by:
updateAll in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface
Since:
$DatabaseSchema $Date: 2004/11/18 02:03:27 $

deleteAll

public void deleteAll(com.jcorporate.expresso.core.dataobjects.DataObject valueObject,
                      boolean deleteChangedCache)
               throws com.jcorporate.expresso.core.dataobjects.DataException
Takes a 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.

Specified by:
deleteAll in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

buildPreparedStoreProcedureSQL

protected java.lang.String buildPreparedStoreProcedureSQL(com.jcorporate.expresso.core.dataobjects.DataObject oneObjectType)
                                                   throws com.jcorporate.expresso.core.db.DBException
Helper Function to build a prepared statement's SQL for running STore Procedure statement.


buildStoreProcedureCallableStatement

protected void buildStoreProcedureCallableStatement(com.jcorporate.expresso.core.dbobj.DBObject criteria,
                                                    java.sql.CallableStatement myCallableStatement)
                                             throws com.jcorporate.expresso.core.dataobjects.DataException
Build and return a FastStringBuffer ring consisting of an SQL 'where' clause using the current field values as criteria for the search. See setCustomWhereClause for information on specifying a more complex where clause.


runStoreProcedure

public void runStoreProcedure(com.jcorporate.expresso.core.dataobjects.DataObject valueObject)
                       throws com.jcorporate.expresso.core.dataobjects.DataException
Run a store procedure identify by the object with keys specified by the valueObject parameter.

Specified by:
runStoreProcedure in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

addBatch

public void addBatch(java.util.List valueObjectList,
                     boolean addChangedFieldsOnly)
              throws com.jcorporate.expresso.core.dataobjects.DataException,
                     com.jcorporate.expresso.core.dataobjects.DuplicateKeyException
Adds an entire batch of DataObjects to the underlying JDBC data source


updateBatch

public void updateBatch(java.util.List valueObjectList,
                        boolean updateChangedFieldsOnly)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Updates an entire batch of DataObjects

Specified by:
updateBatch in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

deleteBatch

public void deleteBatch(java.util.List valueObjectList,
                        boolean deleteWithSetFieldsOnly)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Updates an entire batch of DataObjects

Specified by:
deleteBatch in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface

deleteBatch

public void deleteBatch(java.util.List valueObjectList)
                 throws com.jcorporate.expresso.core.dataobjects.DataException
Deletes an entire batch of DataObjects

Specified by:
deleteBatch in interface com.jcorporate.expresso.core.dataobjects.DataExecutorInterface