org.locomotive.util.cache
Interface RelationalObject
- public interface RelationalObject
Method Summary |
boolean |
delete(java.sql.Connection conn)
The GlobalDBCache calls this method to delete your object
from the database. |
boolean |
existsInDB()
returns the value of the flag which tells whether this object
already exists in the DB or not. |
boolean |
insert(java.sql.Connection conn)
The GlobalDBCache calls this method to create your new object
in the database, if your object DOES NOT already exist in the database. |
boolean |
isDirty()
|
boolean |
load(java.sql.Connection conn,
java.lang.Object key)
The GlobalDBCache calls this method to load your object
from the database. |
boolean |
update(java.sql.Connection conn)
The GlobalDBCache calls this method to write your object
to the database, if your object already exists in the database. |
load
public boolean load(java.sql.Connection conn,
java.lang.Object key)
throws java.sql.SQLException
- The GlobalDBCache calls this method to load your object
from the database.
NOTE: remember to set your dirty flag to false inside this method.
ALSO: remember to set your exists_in_DB flag inside this method
to true or false, depending out whether this object was found.
NOTE 2: even though Java does not allow us to specify whether a
method can be synchronized in an interface, we strongly recommend
that you implement this method as a synchronized method.
- Returns:
- whether this RelationalObject was successfully loaded
(for example, it might not exist in the database).
update
public boolean update(java.sql.Connection conn)
throws java.sql.SQLException
- The GlobalDBCache calls this method to write your object
to the database, if your object already exists in the database.
NOTE: remember to reset your dirty flag to false inside this method!
ALSO: remember to set your exists_in_DB flag to true inside this method.
NOTE 2: we recommend that you implement this method as a
synchronized method.
- Returns:
- whether this object was written to the database. (for
example, this object might not exist in the database)
insert
public boolean insert(java.sql.Connection conn)
throws java.sql.SQLException
- The GlobalDBCache calls this method to create your new object
in the database, if your object DOES NOT already exist in the database.
NOTE: remember to reset your dirty flag to false inside this method!
ALSO: remember to set your exists_in_DB flag to true inside this method.
NOTE 2: we recommend that you implement this method as a
synchronized method.
- Returns:
- whether this object was created in the database.
delete
public boolean delete(java.sql.Connection conn)
throws java.sql.SQLException
- The GlobalDBCache calls this method to delete your object
from the database.
- Returns:
- whether this object was deleted from the database.
ALSO: remember to set your exists_in_DB flag to false inside this
method. (for example, this object might not exist in the database)
existsInDB
public boolean existsInDB()
- returns the value of the flag which tells whether this object
already exists in the DB or not.
isDirty
public boolean isDirty()
- Returns:
- the value of the dirty flag.
The "dirty" flag is used by the GlobalDBCache to determine
whether to write any changes to the database,
at the interval you schedule.