com.strangelight.db
Class OwnableRow

java.lang.Object
  |
  +--com.strangelight.db.TableRow
        |
        +--com.strangelight.db.OwnableRow
All Implemented Interfaces:
Ownable

public abstract class OwnableRow
extends TableRow
implements Ownable

A TableRow which can be associated with a particular owner/user. It does this by requiring the the underlying database table has certain standardized columns:

_last_modified_BY_uid
must be of type INT.
_created_BY_uid
must be of type INT.
_created
must be of type DATETIME.
_last_modified
must be of type TIMESTAMP.
In other words: the SQL CREATE TABLE definition of a database table encapsulated by a subclass of KeyedRow must look something like this:
                 CREATE TABLE MyTableName (
                         id                      int PRIMARY KEY auto_increment,
                         _last_modified          timestamp,
                         _last_modified_BY_uid   int,
                         _created                datetime,
                         _created_BY_uid         int,
                         ...
         

See Also:
KeyedRow

Constructor Summary
OwnableRow()
           
 
Method Summary
 void commit()
          Writes any changes made to this TableRow object back to the database.
 void finalize()
           
 User getUser()
          gets the User who is currently using the database (who may or may not be the "owner" of the object that this database row represents).
 void setUser(User u)
          sets the User who is currently using the database (who may or may not be the "owner" of the object that this database row represents).
 
Methods inherited from class com.strangelight.db.TableRow
drop, getFields, getObject, getString, getTableName, getWhereClause, setObject, setString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OwnableRow

public OwnableRow()
Method Detail

setUser

public void setUser(User u)
sets the User who is currently using the database (who may or may not be the "owner" of the object that this database row represents).

Specified by:
setUser in interface Ownable

getUser

public User getUser()
gets the User who is currently using the database (who may or may not be the "owner" of the object that this database row represents).

Specified by:
getUser in interface Ownable
Returns:
the User currently using the database.

commit

public void commit()
Writes any changes made to this TableRow object back to the database.

This method is called automatically during garbage-collection.

Overrides:
commit in class TableRow

finalize

public void finalize()
Overrides:
finalize in class TableRow