net.sf.borg.model.db.jdbc
Class JdbcBeanDB<T extends KeyedEntity<T>>

java.lang.Object
  extended by net.sf.borg.model.db.jdbc.JdbcDB
      extended by net.sf.borg.model.db.jdbc.JdbcBeanDB<T>
Direct Known Subclasses:
AddrJdbcDB, ApptJdbcDB, LinkJdbcDB, TaskJdbcDB

abstract class JdbcBeanDB<T extends KeyedEntity<T>>
extends JdbcDB

abstract base class for all classes that manage reading/writing of KeyedEntities to and from a JDBC database. also provides an object cache.


Field Summary
 
Fields inherited from class net.sf.borg.model.db.jdbc.JdbcDB
connection_
 
Constructor Summary
JdbcBeanDB()
          Creates a new instance of JdbcDB.
 
Method Summary
(package private) abstract  T createFrom(ResultSet rs)
          Fills in an entity from a result set
protected  void delCache(int key)
           
protected  void emptyCache()
           
(package private) abstract  PreparedStatement getPSAll()
           
(package private) abstract  PreparedStatement getPSOne(int key)
           
 Collection<T> readAll()
          Read all Entities.
protected  T readCache(int key)
           
 T readObj(int key)
          Read a single KeyedEntity from the database by key
 void sync()
          flush the cache
protected  void writeCache(T bean)
           
 
Methods inherited from class net.sf.borg.model.db.jdbc.JdbcDB
beginTransaction, buildDbDir, close, commitTransaction, connect, execSQL, getConnection, getOption, getOptions, getUrl, rollbackTransaction, setOption, toInt, toInt, toStr, toVect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcBeanDB

JdbcBeanDB()
Creates a new instance of JdbcDB.

Method Detail

sync

public void sync()
flush the cache


writeCache

protected void writeCache(T bean)

emptyCache

protected void emptyCache()

delCache

protected void delCache(int key)

readCache

protected T readCache(int key)

readAll

public Collection<T> readAll()
                                             throws Exception
Read all Entities.

Returns:
A collection of all Entities in the DB table
Throws:
Exception

readObj

public T readObj(int key)
                                 throws Exception
Read a single KeyedEntity from the database by key

Parameters:
key - the key
Returns:
the entity
Throws:
Exception - the exception

getPSOne

abstract PreparedStatement getPSOne(int key)
                             throws SQLException
Returns:
a PreparedStatement that reads one entity by key
Throws:
SQLException

getPSAll

abstract PreparedStatement getPSAll()
                             throws SQLException
Returns:
a PreparedStatement that reads all entities from a table
Throws:
SQLException

createFrom

abstract T createFrom(ResultSet rs)
                                      throws SQLException
Fills in an entity from a result set

Parameters:
rs - the result set
Returns:
the entity
Throws:
SQLException


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic