Holger's
Java API

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

All Superinterfaces:
MappingInfo, TransactionRequired
All Known Implementing Classes:
AddressableMapper, BaseDocumentMapper, BaseRowMapper, BeanMapper, DBDocumentStore.Mapper, GenericPropertyEntryMapper, ImageURLEntryMapper, MappedEntryMapper, MessageEntryMapper, MySqlQueryToViewMapper, PropertyMapper, RelationshipStore.Mapper, SerializedEntrySQLMapper, ThumbnailMapper, UserImplMapper, WrappedObjectRowMapper

public interface ObjectRowMapper<T extends DBEntry>
extends MappingInfo, TransactionRequired

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

See Also:
JDBCRowStore, WrappedDBClassStoreMapping, BaseRowMapper

Method Summary
 Stub<T> extractStub(ResultSet rs, Class<T> typeClass)
           
 Object generateNewID()
           
 Connection getConnection()
           
 String[] getRestrictMappedColumns()
          allows to limit the columns retrieved from a ResultSet when loading the data from a table query.
 ResultSet getResultSet(Filter<? super T> filter)
          constructs the ResultSet used for fetching entries that corresponds closest to the filter; note that the filter may be null, in which case the select statement should return all rows.
 ResultSet getStubResultSet(Filter<? super Stub<?>> filter)
          creates and returns the ResultSet used for fetching stubs that corresponds closest to the filter for extracting Stub entries.
 void handleAfterStore(T entry, boolean isInsert)
          called by the store after a given entry is either inserted or updated, so that additional updates (other than providing the RowItem for storage) can take place.
 T instantiate(RowItem row)
          instantiates the DBEntry 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
 void verifyBeforeDelete(Object id)
          called by the store before a given entry is deleted, so that additional checks can easily be incorporated.
 void verifyBeforeStore(T entry, boolean isInsert)
          called by the store before a given entry is either inserted or updated, so that additional checks can easily be incorporated.
 
Methods inherited from interface com.antelmann.sql.MappingInfo
getColumnNames, getColumnsForTopic, getColumnSize, getDisplayColumn, getDisplayNameForColumn, getIDColumn, getMappingForTopic, getSQLTypeforColumn, getTableName, getTableQuery
 

Method Detail

getConnection

Connection getConnection()

generateNewID

Object generateNewID()
                     throws DatabaseException,
                            UnsupportedOperationException
Throws:
DatabaseException
UnsupportedOperationException
See Also:
DBClassStore.generateNewID(), SQLNumberGenerator, TransactionalNumberGenerator

instantiate

T instantiate(RowItem row)
                              throws Exception
instantiates the DBEntry based on the properties in the given row. The given row contains all the columns of the queried ResultSet unless the columns to be retrieved are restricted by getRestrictMappedColumns().

Throws:
Exception

mapToRow

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

Throws:
WrongDataException

verifyBeforeStore

void verifyBeforeStore(T entry,
                       boolean isInsert)
                       throws DatabaseException,
                              SQLException
called by the store before a given entry is either inserted or updated, so that additional checks can easily be incorporated. This method would be called only from within an open transaction.

Parameters:
isInsert - if true, the entry is about to be inserted; if false, it is an update
Throws:
DatabaseException
SQLException

handleAfterStore

void handleAfterStore(T entry,
                      boolean isInsert)
                      throws DatabaseException,
                             SQLException
called by the store after a given entry is either inserted or updated, so that additional updates (other than providing the RowItem for storage) can take place.

Parameters:
isInsert - if true, the entry is about to be inserted; if false, it is an update
Throws:
DatabaseException
SQLException

verifyBeforeDelete

void verifyBeforeDelete(Object id)
                        throws DatabaseException,
                               SQLException
called by the store before a given entry is deleted, so that additional checks can easily be incorporated. This method would be called only from within an open transaction. Note that this method NOT called if DBClassStore.deleteEntries(Filter) is called and JDBCRowStore.isFastDelete() returns is true!

Throws:
WrongDataException - if the deletion is not allowed for semantical reasons
DatabaseException
SQLException

extractStub

Stub<T> extractStub(ResultSet rs,
                    Class<T> typeClass)
                                    throws SQLException
Throws:
SQLException

getResultSet

ResultSet getResultSet(Filter<? super T> filter)
                       throws SQLException
constructs the ResultSet used for fetching entries that corresponds closest to the filter; note that the filter may be null, in which case the select statement should return all rows. The returned ResultSet 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

getStubResultSet

ResultSet getStubResultSet(Filter<? super Stub<?>> filter)
                           throws SQLException
creates and returns the ResultSet used for fetching stubs that corresponds closest to the filter for extracting Stub entries. The filter may be null.

Throws:
SQLException

getRestrictMappedColumns

String[] getRestrictMappedColumns()
allows to limit the columns retrieved from a ResultSet when loading the data from a table query. If the return value is null, all columns are retrieved without restriction. If the return value is an empty array, only the ID column is retrieved. If the return value is a non-empty array, only those columns are retrieved from the query that are contained in this array. The id column is always retrieved.

Returns:
an array of column names that limit which columns are retrieved from a ResultSet when extracting the data into a RowItem; null may be returned.
See Also:
instantiate(RowItem)


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