Holger's
Java API

com.antelmann.sql
Interface ObjectRowMapper<T extends Resource>

All Known Implementing Classes:
BaseRowMapper

public interface ObjectRowMapper<T extends Resource>

provides methods to convert an object to a RowItem and vice versa to facilitate persistent storage with JDBC for simple objects.

See Also:
JDBCRowProxy, BaseRowMapper

Method Summary
 Object generateNewID()
           
 String getIDColumnName()
           
 ResultSet getResultSet(Filter<T> filter)
          constructs the ResultSet that corresponds closesd to the filter; note that the filter may be null, in which case the select statement should return all rows.
 String getTableName()
          generates a (blank) RowItem that tells the caller in what table to look for what value in what field to find the object.
 T instanciate(RowItem row)
          instanciates the Resource based on the properties in the given row
 RowItem mapToRow(T object)
          generates a RowItem containing all relevant properties, so that it can be used to store the object into the database
 

Method Detail

generateNewID

Object generateNewID()
                     throws DatabaseException
Throws:
DatabaseException
See Also:
DBClassStore.generateNewID()

instanciate

T instanciate(RowItem row)
                               throws InstantiationException
instanciates the Resource based on the properties in the given row

Throws:
InstantiationException

getTableName

String getTableName()
generates a (blank) RowItem that tells the caller in what table to look for what value in what field to find the object. Other than null, any parameter should be accepted. The return value must not be null for any ID. An implementation can hence use this method to get a sample RowItem for accessing table and idColumn.

Throws:
IllegalArgumentException - for IDs that are not allowed for a T resource.

getIDColumnName

String getIDColumnName()

getResultSet

ResultSet getResultSet(Filter<T> filter)
                       throws SQLException
constructs the ResultSet that corresponds closesd to the filter; note that the filter may be null, in which case the select statement should return all rows. The returned PreparedStatement should allow at least for all objects accepted by the filter; it may include more, which would then be filtered out by the filter itself.

Throws:
SQLException

mapToRow

RowItem mapToRow(T object)
generates a RowItem containing all relevant properties, so that it can be used to store the object into the database



(c) 2001-2006 Holger Antelmann - all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads