org.openstreetmap.osmosis.core.pgsql.common
Class BaseDao

java.lang.Object
  extended by org.openstreetmap.osmosis.core.pgsql.common.BaseDao
All Implemented Interfaces:
Releasable
Direct Known Subclasses:
ActionDao, EntityDao, EntityFeatureDao, UserDao

public class BaseDao
extends java.lang.Object
implements Releasable

Provides functionality common to all dao implementations.

Author:
Brett Henderson

Constructor Summary
protected BaseDao(DatabaseContext dbCtx)
          Creates a new instance.
 
Method Summary
protected  DatabaseContext getDatabaseContext()
          Provides access to the database context.
protected  java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          Creates a new database prepared statement.
 void release()
          Performs resource cleanup tasks such as closing files, or database connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseDao

protected BaseDao(DatabaseContext dbCtx)
Creates a new instance.

Parameters:
dbCtx - The database context to use for accessing the database.
Method Detail

getDatabaseContext

protected DatabaseContext getDatabaseContext()
Provides access to the database context. In most cases alternative methods such as prepareStatement should be used.

Returns:
The database context.

prepareStatement

protected java.sql.PreparedStatement prepareStatement(java.lang.String sql)
Creates a new database prepared statement. This statement will be automatically released when the dao is released.

Parameters:
sql - The statement to be created.
Returns:
The newly created statement.

release

public void release()
Performs resource cleanup tasks such as closing files, or database connections. This must be called after all processing is complete and may be called multiple times. Implementations must call release on any nested Releasable objects. It should be called within a finally block to ensure it is called in exception scenarios.

Specified by:
release in interface Releasable