org.rimudb
Class RecordBinder

java.lang.Object
  extended by org.rimudb.RecordBinder

public class RecordBinder
extends java.lang.Object

This class is responsible for binding result set values to a record

Author:
Simon Ritchie

Constructor Summary
RecordBinder(TableMetaData tableMetaData)
          Create a RecordBinder.
 
Method Summary
 void bindResultSet(java.sql.ResultSet rs, Record record)
          Bind the ResultSet values to a Record
 void bindResultSetToAutoIncrementKeys(java.sql.ResultSet rs, Record[] records)
          Bind the ResultSet values to the record auto-increment keys.
protected  void bindStatement(java.sql.PreparedStatement ps, WhereList whereList)
          Bind the values from the WhereList to the prepared statement.
 void bindStatementForInsert(java.sql.PreparedStatement ps, Record record)
          Bind the values from the Record to the prepared statement
protected  void bindStatementForUpdate(java.sql.PreparedStatement ps, Record oldRecord, Record newRecord, OptimisticLocking optimisticLocking, java.util.List<java.lang.String> changedPropertyList)
          Bind the values from the record to a prepared statement used for update.
static void bindValue(java.sql.PreparedStatement ps, int columnIndex, java.lang.Object value)
           
static void bindValue(java.sql.PreparedStatement ps, int columnIndex, java.lang.Object value, int sqlType, boolean doVersionIncrement)
           
static java.lang.Object getDefaultValue(int sqlType)
          Return the default value
static java.lang.Object getResultSetValue(java.sql.ResultSet rs, int columnIndex, int sqlType)
          Return the value from the ResultSet for the columnIndex.
 int lookupColumnIndex(java.lang.String columnName, java.sql.ResultSet rs)
          Lookup the column name to get the index in the result set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RecordBinder

public RecordBinder(TableMetaData tableMetaData)
Create a RecordBinder.

Parameters:
tableMetaData - TableMetaData
Method Detail

bindResultSet

public void bindResultSet(java.sql.ResultSet rs,
                          Record record)
                   throws RimuDBException
Bind the ResultSet values to a Record

Parameters:
rs - ResultSet
record - Record
Throws:
java.sql.SQLException
RimuDBException

lookupColumnIndex

public int lookupColumnIndex(java.lang.String columnName,
                             java.sql.ResultSet rs)
                      throws RimuDBException
Lookup the column name to get the index in the result set

Parameters:
columnName - String
rs - ResultSet
Returns:
int
Throws:
java.sql.SQLException
RimuDBException

bindStatementForUpdate

protected void bindStatementForUpdate(java.sql.PreparedStatement ps,
                                      Record oldRecord,
                                      Record newRecord,
                                      OptimisticLocking optimisticLocking,
                                      java.util.List<java.lang.String> changedPropertyList)
                               throws java.sql.SQLException
Bind the values from the record to a prepared statement used for update. i.e. UPDATE table SET COLUMN1 = ?, COLUMN2 = ?, COLUMN3 = ? WHERE COLUMN4 = ? AND COLUMN5 = ?

Parameters:
ps - PreparedStatement
oldRecord - Record
newRecord - Record
optimisticLocking - OptimisticLocking
changedPropertyList - List
Throws:
java.sql.SQLException

bindStatement

protected void bindStatement(java.sql.PreparedStatement ps,
                             WhereList whereList)
                      throws java.sql.SQLException
Bind the values from the WhereList to the prepared statement.

Parameters:
ps - PreparedStatement
whereList - WhereList
Throws:
java.sql.SQLException

bindStatementForInsert

public void bindStatementForInsert(java.sql.PreparedStatement ps,
                                   Record record)
                            throws java.sql.SQLException
Bind the values from the Record to the prepared statement

Parameters:
ps - PreparedStatement
record - Record
Throws:
java.sql.SQLException

bindResultSetToAutoIncrementKeys

public void bindResultSetToAutoIncrementKeys(java.sql.ResultSet rs,
                                             Record[] records)
                                      throws java.sql.SQLException,
                                             RimuDBException
Bind the ResultSet values to the record auto-increment keys.

Parameters:
rs - ResultSet
records - Record[]
Throws:
java.sql.SQLException
RimuDBException

getResultSetValue

public static java.lang.Object getResultSetValue(java.sql.ResultSet rs,
                                                 int columnIndex,
                                                 int sqlType)
                                          throws RimuDBException
Return the value from the ResultSet for the columnIndex.

Parameters:
rs - ResultSet
columnIndex - int
sqlType -
Returns:
Object
Throws:
java.sql.SQLException
RimuDBException

getDefaultValue

public static java.lang.Object getDefaultValue(int sqlType)
Return the default value


bindValue

public static void bindValue(java.sql.PreparedStatement ps,
                             int columnIndex,
                             java.lang.Object value,
                             int sqlType,
                             boolean doVersionIncrement)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

bindValue

public static void bindValue(java.sql.PreparedStatement ps,
                             int columnIndex,
                             java.lang.Object value)
                      throws java.sql.SQLException
Parameters:
ps -
columnIndex -
value -
Throws:
java.sql.SQLException


Copyright © 2008-2011 Simon Ritchie. All Rights Reserved.