ir.thinkinsql
Class BaseRecord

java.lang.Object
  extended by ir.thinkinsql.BaseRow
      extended by ir.thinkinsql.BaseRecord
All Implemented Interfaces:
IRecord, IRow, java.lang.Cloneable

public abstract class BaseRecord
extends BaseRow
implements IRecord, java.lang.Cloneable

Provides an IRecord adapter, and BaseRow enhancer.


Constructor Summary
BaseRecord()
           
 
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.
 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 class ir.thinkinsql.BaseRow
afterRead, getColumns, getFields, getTemporaryProperty, putTemporaryProperty, setValueSpecial, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ir.thinkinsql.IRecord
getTable
 
Methods inherited from interface ir.thinkinsql.IRow
afterRead, getColumns, getDatabase, getFields, getTemporaryProperty, putTemporaryProperty, setValueSpecial
 

Constructor Detail

BaseRecord

public BaseRecord()
Method Detail

afterDelete

public void afterDelete(Database db)
                 throws java.lang.Exception
Description copied from interface: IRecord
Called to perform extra processing after record has been deleted.

Specified by:
afterDelete in interface IRecord
Throws:
java.lang.Exception

afterInsert

public void afterInsert(Database db)
                 throws java.lang.Exception
Description copied from interface: IRecord
Called to perform extra processing after record has been inserted

Specified by:
afterInsert in interface IRecord
Throws:
java.lang.Exception

afterUpdate

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

Specified by:
afterUpdate in interface IRecord
Throws:
java.lang.Exception

beforeDelete

public void beforeDelete(Database db)
                  throws java.lang.Exception
Description copied from interface: IRecord
Called to perform extra processing before record is deleted

Specified by:
beforeDelete in interface IRecord
Throws:
java.lang.Exception

beforeInsert

public void beforeInsert(Database db)
                  throws java.lang.Exception
Description copied from interface: IRecord
Called to perform extra processing before record is inserted

Specified by:
beforeInsert in interface IRecord
Throws:
java.lang.Exception

beforeUpdate

public void beforeUpdate(Database db)
                  throws java.lang.Exception
Description copied from interface: IRecord
Called to perform extra processing before record is updated

Specified by:
beforeUpdate in interface IRecord
Throws:
java.lang.Exception

bindSpecial

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

Specified by:
bindSpecial in interface IRecord
Throws:
java.lang.Exception

delete

public boolean delete()
               throws java.lang.Exception
Description copied from interface: IRecord
Deletes row from home database, returns whether row was actually deleted.

Specified by:
delete in interface IRecord
Throws:
java.lang.Exception

exists

public boolean exists()
               throws java.lang.Exception
Description copied from interface: IRecord
Returns whether row with embodied key exists in home database.

Specified by:
exists in interface IRecord
Throws:
java.lang.Exception

getChanges

public java.util.List<ChangedColumn> getChanges()
                                         throws java.lang.Exception
Description copied from interface: IRecord
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.

Specified by:
getChanges in interface IRecord
Throws:
java.lang.Exception

getKey

public java.lang.String[] getKey()
                          throws java.lang.Exception
Description copied from interface: IRecord
Returns key to be used to find rows. Return null to use database meta data.

Specified by:
getKey in interface IRecord
Throws:
java.lang.Exception

getNullableNumerics

public java.lang.String[] getNullableNumerics()
Description copied from interface: IRecord
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.

Specified by:
getNullableNumerics in interface IRecord

getOldValue

public IRecord getOldValue()
Description copied from interface: IRecord
Returns value of record when makeClean was last called.

Specified by:
getOldValue in interface IRecord

getSequenceColumn

public java.lang.String getSequenceColumn()
Description copied from interface: IRecord
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.

Specified by:
getSequenceColumn in interface IRecord

getSequenceName

public java.lang.String getSequenceName()
Description copied from interface: IRecord
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.

Specified by:
getSequenceName in interface IRecord

insert

public void insert()
            throws java.lang.Exception
Description copied from interface: IRecord
Inserts row to home database.

Specified by:
insert in interface IRecord
Throws:
java.lang.Exception

isDirty

public boolean isDirty()
Description copied from interface: IRecord
Indicates whether record has been modified since it was last made clean.

Specified by:
isDirty in interface IRecord

makeClean

public void makeClean()
Description copied from interface: IRecord
Explicitly makes record clean

Specified by:
makeClean in interface IRecord

makeDirty

public void makeDirty()
Description copied from interface: IRecord
Explicitly makes record dirty - could be used to force an update.

Specified by:
makeDirty in interface IRecord

select

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

Specified by:
select in interface IRecord
Throws:
java.lang.Exception

update

public boolean update()
               throws java.lang.Exception
Description copied from interface: IRecord
Updates row, returns whether an update occurred.

Specified by:
update in interface IRecord
Throws:
java.lang.Exception

write

public boolean write()
              throws java.lang.Exception
Description copied from interface: IRecord
Executes exists() ? update() : insert()

Specified by:
write in interface IRecord
Throws:
java.lang.Exception