ir.thinkinsql
Interface IRecord

All Superinterfaces:
IRow
All Known Implementing Classes:
BaseRecord

public interface IRecord
extends IRow

Specifies the behavior of objects that represent a row of a table.


Method Summary
 void afterDelete(Database db)
          Called to perform extra processing after record has been deleted.
 void afterInsert(Database db)
          Called to perform extra processing after record has been inserted
 void afterUpdate(Database db, IRecord oldValue)
          Called to perform extra processing after record has been updated
 void beforeDelete(Database db)
          Called to perform extra processing before record is deleted
 void beforeInsert(Database db)
          Called to perform extra processing before record is inserted
 void beforeUpdate(Database db)
          Called to perform extra processing before record is updated
 boolean bindSpecial(Database db, java.sql.PreparedStatement ps, int pidx, java.lang.String columnName, java.lang.String propertyName)
          Provides a plug point for implementers to override default binding for the named column.
 boolean delete()
          Deletes row from home database, returns whether row was actually deleted.
 boolean exists()
          Returns whether row with embodied key exists in home database.
 java.util.List<ChangedColumn> getChanges()
          Returns which columns have changed since instantiation or last makeClean.
 java.lang.String[] getKey()
          Returns key to be used to find rows.
 java.lang.String[] getNullableNumerics()
          Returns names of columns that should update the database as null rather than 0, which is most often used for optional foreign keys.
 IRecord getOldValue()
          Returns value of record when makeClean was last called.
 java.lang.String getSequenceColumn()
          Returns record's sequence column, or null if not applicable.
 java.lang.String getSequenceName()
          Returns record's sequence name, or null if not applicable.
 java.lang.String getTable()
          Gets the record's home table.
 void insert()
          Inserts row to home database.
 boolean isDirty()
          Indicates whether record has been modified since it was last made clean.
 void makeClean()
          Explicitly makes record clean
 void makeDirty()
          Explicitly makes record dirty - could be used to force an update.
 boolean select(java.lang.Object... keys)
          Selects row with passed keys, or embodied keys if none are passed, from home database.
 boolean update()
          Updates row, returns whether an update occurred.
 boolean write()
          Executes exists() ? update() : insert()
 
Methods inherited from interface ir.thinkinsql.IRow
afterRead, getColumns, getDatabase, getFields, getTemporaryProperty, putTemporaryProperty, setValueSpecial
 

Method Detail

afterDelete

void afterDelete(Database db)
                 throws java.lang.Exception
Called to perform extra processing after record has been deleted.

Throws:
java.lang.Exception

afterInsert

void afterInsert(Database db)
                 throws java.lang.Exception
Called to perform extra processing after record has been inserted

Throws:
java.lang.Exception

afterUpdate

void afterUpdate(Database db,
                 IRecord oldValue)
                 throws java.lang.Exception
Called to perform extra processing after record has been updated

Throws:
java.lang.Exception

beforeDelete

void beforeDelete(Database db)
                  throws java.lang.Exception
Called to perform extra processing before record is deleted

Throws:
java.lang.Exception

beforeInsert

void beforeInsert(Database db)
                  throws java.lang.Exception
Called to perform extra processing before record is inserted

Throws:
java.lang.Exception

beforeUpdate

void beforeUpdate(Database db)
                  throws java.lang.Exception
Called to perform extra processing before record is updated

Throws:
java.lang.Exception

bindSpecial

boolean bindSpecial(Database db,
                    java.sql.PreparedStatement ps,
                    int pidx,
                    java.lang.String columnName,
                    java.lang.String propertyName)
                    throws java.lang.Exception
Provides a plug point for implementers to override default binding for the named column.

Throws:
java.lang.Exception

delete

boolean delete()
               throws java.lang.Exception
Deletes row from home database, returns whether row was actually deleted.

Throws:
java.lang.Exception

exists

boolean exists()
               throws java.lang.Exception
Returns whether row with embodied key exists in home database.

Throws:
java.lang.Exception

getChanges

java.util.List<ChangedColumn> getChanges()
                                         throws java.lang.Exception
Returns which columns have changed since instantiation or last makeClean. Will return an empty list if no changes are detected. Will return all columns with all old values null in the case of an insert.

Throws:
java.lang.Exception

getKey

java.lang.String[] getKey()
                          throws java.lang.Exception
Returns key to be used to find rows. Return null to use database meta data.

Throws:
java.lang.Exception

getNullableNumerics

java.lang.String[] getNullableNumerics()
Returns names of columns that should update the database as null rather than 0, which is most often used for optional foreign keys. Nullable string columns will update as null instead of "". Return null or empty String[] if not applicable.


getOldValue

IRecord getOldValue()
Returns value of record when makeClean was last called.


getSequenceColumn

java.lang.String getSequenceColumn()
Returns record's sequence column, or null if not applicable. Note this will not be used if the table has an auto_increment column, so you can include it and have db-portable code.


getSequenceName

java.lang.String getSequenceName()
Returns record's sequence name, or null if not applicable. Note this will not be used if the table has an auto_increment column, so you can include it and have db-portable code.


getTable

java.lang.String getTable()
Gets the record's home table.


insert

void insert()
            throws java.lang.Exception
Inserts row to home database.

Throws:
java.lang.Exception

isDirty

boolean isDirty()
Indicates whether record has been modified since it was last made clean.


makeClean

void makeClean()
Explicitly makes record clean


makeDirty

void makeDirty()
Explicitly makes record dirty - could be used to force an update.


select

boolean select(java.lang.Object... keys)
               throws java.lang.Exception
Selects row with passed keys, or embodied keys if none are passed, from home database. Returns whether row was found.

Throws:
java.lang.Exception

update

boolean update()
               throws java.lang.Exception
Updates row, returns whether an update occurred.

Throws:
java.lang.Exception

write

boolean write()
              throws java.lang.Exception
Executes exists() ? update() : insert()

Throws:
java.lang.Exception