|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.sql.WrappedObjectRowMapper<T>
public class WrappedObjectRowMapper<T extends DBEntry>
eases the task of wrapping a given mapper and overriding only certain aspects of its behavior.
All ObjectRowMapper-implementing methods are delegated to the embedded mapper.
Often, a WrappedDBClassStoreMapping does a better job.
WrappedDBClassStoreMapping| Field Summary | |
|---|---|
protected ObjectRowMapper<T> |
mapper
|
| Constructor Summary | |
|---|---|
WrappedObjectRowMapper(ObjectRowMapper<T> mapper)
|
|
| Method Summary | |
|---|---|
Stub<T> |
extractStub(ResultSet rs,
Class<T> typeClass)
|
Object |
generateNewID()
|
String[] |
getColumnNames()
returns all the columns that are retrieved by the mapper when querying the database); the column names for the ID column and display column are included in the returned array. |
String[] |
getColumnsForTopic(Object topic)
allows to determine whether there are any columns that are applicable for the given topic |
int |
getColumnSize(String column)
allows to determine the size of the given column name. |
Connection |
getConnection()
|
String |
getDisplayColumn()
for use in stubs (in case a single column is used as a display value) |
String |
getDisplayNameForColumn(String column)
returns a name suitable for display in a GUI if different from the column name used in the database |
String |
getIDColumn()
specifies the column where the ID of the entry is mapped to |
String |
getMappingForTopic(Object topic)
allows to determine whether a specific given topic maps to a distinct table, query or column name. |
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. |
int |
getSQLTypeforColumn(String column)
allows to determine the SQL-type for a given column name |
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. |
String |
getTableName()
provides the name of the table that stores the data for the store |
String |
getTableQuery()
if querying involves something different than just selecting all columns of the table, this method returns the string used to replace the table name in a query. |
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 |
ObjectRowMapper<T> |
unwrap()
returns the embedded mapper that was given to the constructor |
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 class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ObjectRowMapper<T extends DBEntry> mapper
| Constructor Detail |
|---|
public WrappedObjectRowMapper(ObjectRowMapper<T> mapper)
| Method Detail |
|---|
public ObjectRowMapper<T> unwrap()
unwrap in interface Wrapped<ObjectRowMapper<T extends DBEntry>>
public Stub<T> extractStub(ResultSet rs,
Class<T> typeClass)
throws SQLException
extractStub in interface ObjectRowMapper<T extends DBEntry>SQLException
public Object generateNewID()
throws DatabaseException,
UnsupportedOperationException
generateNewID in interface ObjectRowMapper<T extends DBEntry>DatabaseException
UnsupportedOperationExceptionDBClassStore.generateNewID(),
SQLNumberGenerator,
TransactionalNumberGeneratorpublic Connection getConnection()
getConnection in interface ObjectRowMapper<T extends DBEntry>public String getDisplayColumn()
MappingInfo
getDisplayColumn in interface MappingInfopublic String getIDColumn()
MappingInfo
getIDColumn in interface MappingInfo
public ResultSet getResultSet(Filter<? super T> filter)
throws SQLException
ObjectRowMapper
getResultSet in interface ObjectRowMapper<T extends DBEntry>SQLException
public ResultSet getStubResultSet(Filter<? super Stub<?>> filter)
throws SQLException
ObjectRowMapper
getStubResultSet in interface ObjectRowMapper<T extends DBEntry>SQLExceptionpublic String getTableName()
MappingInfo
getTableName in interface MappingInfoMappingInfo.getTableQuery()public String getTableQuery()
MappingInfoMappingInfo.getTableName() is used in all cases.
If non-null, this variable would have a value like '(select a.field1, b.* from a, b where a.id=b.id) as t1'.
getTableQuery in interface MappingInfoMappingInfo.getTableName()
public T instantiate(RowItem row)
throws Exception
ObjectRowMapperObjectRowMapper.getRestrictMappedColumns().
instantiate in interface ObjectRowMapper<T extends DBEntry>Exception
public RowItem mapToRow(T object)
throws WrongDataException
ObjectRowMapper
mapToRow in interface ObjectRowMapper<T extends DBEntry>WrongDataException
public void verifyBeforeDelete(Object id)
throws DatabaseException,
SQLException
ObjectRowMapperDBClassStore.deleteEntries(Filter)
is called and JDBCRowStore.isFastDelete() returns is true!
verifyBeforeDelete in interface ObjectRowMapper<T extends DBEntry>WrongDataException - if the deletion is not allowed for semantical reasons
DatabaseException
SQLException
public void verifyBeforeStore(T entry,
boolean isInsert)
throws DatabaseException,
SQLException
ObjectRowMapper
verifyBeforeStore in interface ObjectRowMapper<T extends DBEntry>isInsert - if true, the entry is about to be inserted; if false, it is an update
DatabaseException
SQLException
public void handleAfterStore(T entry,
boolean isInsert)
throws DatabaseException,
SQLException
ObjectRowMapper
handleAfterStore in interface ObjectRowMapper<T extends DBEntry>isInsert - if true, the entry is about to be inserted; if false, it is an update
DatabaseException
SQLExceptionpublic String getMappingForTopic(Object topic)
MappingInfo
getMappingForTopic in interface MappingInfopublic String[] getColumnsForTopic(Object topic)
MappingInfo
getColumnsForTopic in interface MappingInfopublic String[] getColumnNames()
MappingInfo
getColumnNames in interface MappingInfoMappingInfo.getTableName(),
MappingInfo.getTableQuery(),
MappingInfo.getIDColumn(),
MappingInfo.getDisplayColumn()public String getDisplayNameForColumn(String column)
MappingInfo
getDisplayNameForColumn in interface MappingInfo
public int getSQLTypeforColumn(String column)
throws IllegalArgumentException
MappingInfo
getSQLTypeforColumn in interface MappingInfoIllegalArgumentException - if the given column is not knownTypes
public int getColumnSize(String column)
throws IllegalArgumentException
MappingInfo
getColumnSize in interface MappingInfoIllegalArgumentException - if the given column is not knownpublic String[] getRestrictMappedColumns()
ObjectRowMapper
getRestrictMappedColumns in interface ObjectRowMapper<T extends DBEntry>ResultSet when extracting the data into a RowItem; null may be returned.ObjectRowMapper.instantiate(RowItem)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||