Save This Page
Home » jboss-5.0.0.CR1-src » org » jboss » ejb » plugins » jaws » jdbc » [javadoc | source]
org.jboss.ejb.plugins.jaws.jdbc
abstract public class: JDBCCommand [javadoc | source]
java.lang.Object
   org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand

Direct Known Subclasses:
    JDBCCreateEntityCommand, JDBCFindAllCommand, JDBCFinderCommand, JDBCInitCommand, JDBCStoreEntityCommand, JDBCLoadEntityCommand, JDBCUpdateCommand, JDBCBeanExistsCommand, JDBCPreloadFinderCommand, JDBCRemoveEntityCommand, JDBCDefinedFinderCommand, JDBCDestroyCommand, JDBCPreloadByPrimaryKeyCommand, JDBCFindByCommand, JDBCQueryCommand

Abstract superclass for all JAWS Commands that use JDBC directly. Provides a Template Method for jdbcExecute(), default implementations for some of the methods called by this template, and a bunch of utility methods that database commands may need to call.
Nested Class Summary:
class  JDBCCommand.WorkaroundInputStream   
Field Summary
protected  JDBCCommandFactory factory     
protected  JawsEntityMetaData jawsEntity     
protected  String name     
Constructor:
 protected JDBCCommand(JDBCCommandFactory factory,
    String name) 
    Construct a JDBCCommand with given factory and name.
    Parameters:
    factory - the factory which was used to create this JDBCCommand, which is also used as a common repository, shared by all an entity's Commands.
    name - the name to be used when tracing execution.
Method from org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand Summary:
executeStatementAndHandleResult,   getCMPFieldValue,   getConnection,   getJDBCType,   getJDBCTypeName,   getJawsCMPFieldJDBCType,   getName,   getPkColumnList,   getPkColumnWhereList,   getPkFieldValue,   getResultObject,   getResultObject,   getSQL,   getState,   isBinaryType,   jdbcExecute,   setCMPFieldValue,   setParameter,   setParameters,   setPrimaryKeyParameters,   setSQL
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.ejb.plugins.jaws.jdbc.JDBCCommand Detail:
 abstract protected Object executeStatementAndHandleResult(PreparedStatement stmt,
    Object argOrArgs) throws Exception
    Executes the PreparedStatement and handles result of successful execution. This is implemented in subclasses for queries and updates.
 protected Object getCMPFieldValue(Object instance,
    CMPFieldMetaData fieldMetaData) throws IllegalAccessException 
 protected Connection getConnection() throws SQLException 
    Get a database connection
 protected final int getJDBCType(String name) 
    Gets the integer JDBC type code corresponding to the given name.
 protected final String getJDBCTypeName(int jdbcType) 
    Gets the JDBC type name corresponding to the given type code.
 protected int getJawsCMPFieldJDBCType(CMPFieldMetaData fieldMetaData) 
 public String getName() 
    return the name of this command
 protected final String getPkColumnList() 
    Returns the comma-delimited list of primary key column names for this entity.
 protected final String getPkColumnWhereList() 
    Returns the string to go in a WHERE clause based on the entity's primary key.
 protected Object getPkFieldValue(Object pk,
    PkFieldMetaData pkFieldMetaData) throws IllegalAccessException 
 protected Object getResultObject(ResultSet rs,
    int idx,
    Class destination) throws SQLException 
    Used for all retrieval of results from ResultSets. Implements tracing, and allows some tweaking of returned types.
 protected Object getResultObject(ResultSet rs,
    int idx,
    CMPFieldMetaData cmpField) throws SQLException 
    Wrapper around getResultObject(ResultSet rs, int idx, Class destination).
 protected String getSQL(Object argOrArgs) throws Exception 
    Gets the SQL to be used in the PreparedStatement. The default implementation returns the sql field value. This is appropriate in all cases where static SQL can be constructed in the Command constructor. Override if dynamically-generated SQL, based on the arguments given to execute(), is needed.
 protected Object[] getState(EntityEnterpriseContext ctx) 
 protected final boolean isBinaryType(int jdbcType) 
    Returns true if the JDBC type should be (de-)serialized as a binary stream and false otherwise.
 protected Object jdbcExecute(Object argOrArgs) throws Exception 
    Template method handling the mundane business of opening a database connection, preparing a statement, setting its parameters, executing the prepared statement, handling the result, and cleaning up.
 protected  void setCMPFieldValue(Object instance,
    CMPFieldMetaData fieldMetaData,
    Object value) throws IllegalAccessException 
 protected  void setParameter(PreparedStatement stmt,
    int idx,
    int jdbcType,
    Object value) throws SQLException 
    Sets a parameter in this Command's PreparedStatement. Handles null values, and provides tracing.
 protected  void setParameters(PreparedStatement stmt,
    Object argOrArgs) throws Exception 
    Default implementation does nothing. Override if parameters need to be set.
 protected int setPrimaryKeyParameters(PreparedStatement stmt,
    int parameterIndex,
    Object id) throws SQLException, IllegalAccessException 
    Sets the PreparedStatement parameters for a primary key in a WHERE clause.
 protected  void setSQL(String sql) 
    Used to set static SQL in subclass constructors.