com.objectwave.persist.sqlConstruction
Class SQLModifier

java.lang.Object
  |
  +--com.objectwave.persist.sqlConstruction.SQLObject
        |
        +--com.objectwave.persist.sqlConstruction.SQLModifier
All Implemented Interfaces:
SQLAssembler
Direct Known Subclasses:
SQLInsert, SQLUpdate

public abstract class SQLModifier
extends SQLObject
implements SQLAssembler

Common behavior necessary for both inserts and updates to through JDBC.

Version:
$Id: SQLModifier.java,v 2.1 2001/11/08 20:38:33 dave_hoag Exp $
Author:
Dave Hoag
See Also:
com.objectwave.persist.RDBBroker

Field Summary
protected  java.lang.String[] columnList
           
protected  int[] sqlTypes
           
protected  int valueCount
           
protected  java.lang.Object[] valueList
           
 
Fields inherited from class com.objectwave.persist.sqlConstruction.SQLObject
availableForPool, table
 
Constructor Summary
SQLModifier()
           
 
Method Summary
 void addColumnList(java.lang.String[] columns)
          Deprecated.  
 void addColumnValue(java.lang.String columnName, java.lang.Object value)
           
 void addValueList(java.lang.Object[] values)
          Deprecated.  
protected  void bindValue(java.sql.PreparedStatement stmt, int index, java.lang.Object value, int sqlType, boolean verbose)
          Bind the data to the PreparedStatement at the specified index.
 void bindValues(java.sql.PreparedStatement prepStmt, java.lang.Class persistenceClass, boolean verbose)
          Bind data to a prepared statement.
 void clean()
          We pool these objects for reuse.
 void copyValuesFrom(SQLModifier sql)
          Used by prepared statements to copy the values from on SQLModifier to another.
 RDBBroker getBroker()
           
 java.lang.String[] getColumnList()
           
abstract  java.lang.String getPreparedString()
           
abstract  java.lang.StringBuffer getSqlStatement()
          Gets the SqlStatement attribute of the SQLModifier object
 java.lang.Object[] getValueList()
           
protected  void growLists(int length)
           
 void setBroker(RDBBroker newValue)
           
 void setValues(java.lang.Object[] valueList)
          Modify the valueList to use the new column/value mapping.
 
Methods inherited from class com.objectwave.persist.sqlConstruction.SQLObject
formatValue, getDefaultFormatter, getObjectFormatter, insertWhereClause, isAvailableForPool, setAvailableForPool, setObjectFormatter, setTableName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnList

protected java.lang.String[] columnList

valueList

protected java.lang.Object[] valueList

valueCount

protected int valueCount

sqlTypes

protected int[] sqlTypes
Constructor Detail

SQLModifier

public SQLModifier()
Method Detail

setBroker

public void setBroker(RDBBroker newValue)
Parameters:
newValue - com.objectwave.persist.RDBBroker

setValues

public void setValues(java.lang.Object[] valueList)
Modify the valueList to use the new column/value mapping. The columnList should have the same length as the valueList, and they should both have the same # of arguments as the lists currently held by the object. Failure to meet these requirements will cause ArrayOutOfBoundsExceptions.

Parameters:
valueList - java.lang.Object[]

getBroker

public RDBBroker getBroker()
Returns:
com.objectwave.persist.RDBBroker

getColumnList

public java.lang.String[] getColumnList()
Returns:
java.lang.String[]

getPreparedString

public abstract java.lang.String getPreparedString()
Returns:
java.lang.String

getSqlStatement

public abstract java.lang.StringBuffer getSqlStatement()
Gets the SqlStatement attribute of the SQLModifier object

Specified by:
getSqlStatement in interface SQLAssembler
Returns:
The SqlStatement value

getValueList

public java.lang.Object[] getValueList()
Returns:
java.lang.Object[]

clean

public void clean()
We pool these objects for reuse. Before returning the object to the pool, clean it up by removing all old values.

Overrides:
clean in class SQLObject

addColumnValue

public void addColumnValue(java.lang.String columnName,
                           java.lang.Object value)
Parameters:
columnName - The feature to be added to the ColumnValue attribute
value - The feature to be added to the ColumnValue attribute

growLists

protected void growLists(int length)
Parameters:
length -

addColumnList

public void addColumnList(java.lang.String[] columns)
Deprecated.  

Add the column names to the list of columns to insert.

Parameters:
columns - The feature to be added to the ColumnList attribute

addValueList

public void addValueList(java.lang.Object[] values)
Deprecated.  

Add values to the list of values to insert. This should match exactly with addColumnList.

Parameters:
values - The feature to be added to the ValueList attribute

bindValue

protected void bindValue(java.sql.PreparedStatement stmt,
                         int index,
                         java.lang.Object value,
                         int sqlType,
                         boolean verbose)
                  throws java.sql.SQLException
Bind the data to the PreparedStatement at the specified index. All data is bound to the prepared statement via the stmt.setString(index, value) method. This is known to work for Oracle and it is assumed to work for other databases. The only exception to to this rule involved Serialized objects and Binary database field types. The stmt.setBytes(index, bytes) method is used for data of the binary type.

Parameters:
stmt - java.sql.PreparedStatement The statement that is being reused.
index - int The index of the value in the prepared statement.
value - java.lang.Object The object to store in the database.
sqlType - int The known database column type to which the data is being stored.
verbose -
Throws:
java.sql.SQLException

bindValues

public void bindValues(java.sql.PreparedStatement prepStmt,
                       java.lang.Class persistenceClass,
                       boolean verbose)
                throws java.sql.SQLException,
                       QueryException
Bind data to a prepared statement.

Parameters:
persistenceClass - The persistent class we are updating. Used for a query to determine sql types.
verbose - boolean Should we be verbose about this effort?
prepStmt -
Throws:
java.sql.SQLException - An unexcepted database exception.
QueryException - An exception generated by JGrinder.

copyValuesFrom

public void copyValuesFrom(SQLModifier sql)
Used by prepared statements to copy the values from on SQLModifier to another.

Parameters:
sql - The source SQLModifier from which to take values.