|
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.BaseRowMapper<T>
com.antelmann.sql.GenericPropertyEntryMapper<T>
public class GenericPropertyEntryMapper<T extends PropertyEntry>
provides an easy way to map a table to a PropertyEntry class;
this implementation makes several (common) assumptions about the mapping.
All properties are mapped to column values.
Unless a PropertyEntryFactory is supplied, the PropertyEntry class must have a
constructor that uses an Object for the ID and then a Map for the properties,
like PropertyEntryImpl.PropertyEntryImpl(Object, Map).
If no IDFactory is given, the ID column is assumed to store Integer objects,
which is relevant for the generation of new IDs.
GenericPropertyEntryStore| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.antelmann.util.Converter |
|---|
Converter.Adapter<T1,T2> |
| Field Summary |
|---|
| Fields inherited from class com.antelmann.sql.BaseRowMapper |
|---|
db, helper |
| Constructor Summary | |
|---|---|
GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
Class<T> type)
uses reflection to utilize the constructor that takes the ID and then the properties as a map |
|
GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
IDFactory idFactory,
Class<T> type)
|
|
GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
PropertyEntryFactory<T> factory,
Class<T> type)
uses the factory to generate instances; either factory or type must not be null |
|
GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
String displayColumn,
Class<T> type)
uses reflection to utilize the constructor that takes the ID and then the properties as a map |
|
GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
String displayColumn,
PropertyEntryFactory<T> factory,
Class<T> type)
uses the factory to generate instances; either factory or type must not be null |
|
GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
String displayColumn,
PropertyEntryFactory<T> factory,
Class<T> type,
IDFactory idFactory)
uses the factory to generate instances; either factory or type must not be null |
|
GenericPropertyEntryMapper(DBClassStore<?> refStore,
Class<T> type)
|
|
GenericPropertyEntryMapper(DBClassStore<?> refStore,
PropertyEntryFactory<T> factory,
Class<T> type,
IDFactory idFactory)
|
|
| Method Summary | |
|---|---|
Object |
generateNewID()
simply returns getNextIntID(), unless an IDFactory was provided |
protected Map<String,Object> |
generateRowProperties(T entry)
simply returns entry.getProperties() and 'translates' it if BaseRowMapper.isTranslate() is set |
String |
getDisplayProperty()
if the returned String is non-null and T is an EntryHeader,
the appropriate value will be set accordingly. |
T |
instantiate(RowItem row)
instantiates the DBEntry based on the properties in the given row. |
void |
setDisplayProperty(String displayProperty)
allows to specify the display property for EntryHeader instances. |
void |
setTableQuery(String tableQuery)
allows to set a query for mapping the data instead of just using the table name. |
void |
setTableQuery(String tableQuery,
String newIdColumn)
in addition to setting a table query, this also allows to change the id column (often required to ensure the uniqueness of the id column in a query that may contain the column multiple times). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
Class<T> type)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
String displayColumn,
Class<T> type)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
PropertyEntryFactory<T> factory,
Class<T> type)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
IDFactory idFactory,
Class<T> type)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
String displayColumn,
PropertyEntryFactory<T> factory,
Class<T> type)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(Database<Connection> db,
String table,
String idColumn,
String displayColumn,
PropertyEntryFactory<T> factory,
Class<T> type,
IDFactory idFactory)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(DBClassStore<?> refStore,
Class<T> type)
throws DatabaseException
DatabaseException
public GenericPropertyEntryMapper(DBClassStore<?> refStore,
PropertyEntryFactory<T> factory,
Class<T> type,
IDFactory idFactory)
throws DatabaseException
DatabaseException| Method Detail |
|---|
public String getDisplayProperty()
EntryHeader,
the appropriate value will be set accordingly.
This value is ignored if T (the entry class) is not an EntryHeader.
setDisplayProperty(String),
EntryHeader.setDisplayProperty(String)
public void setDisplayProperty(String displayProperty)
throws IllegalStateException
EntryHeader instances.
IllegalStateException - if T is not an EntryHeader class.getDisplayProperty()
protected Map<String,Object> generateRowProperties(T entry)
throws WrongDataException
BaseRowMapper.isTranslate() is set
generateRowProperties in class BaseRowMapper<T extends PropertyEntry>WrongDataExceptionBaseRowMapper.setTranslate(boolean),
BaseRowMapper.toSQLMap(Map)
public Object generateNewID()
throws DatabaseException,
UnsupportedOperationException
generateNewID in interface ObjectRowMapper<T extends PropertyEntry>generateNewID in class BaseRowMapper<T extends PropertyEntry>DatabaseException
UnsupportedOperationExceptionDBClassStore.generateNewID(),
SQLNumberGenerator,
TransactionalNumberGenerator
public T instantiate(RowItem row)
throws Exception
ObjectRowMapperObjectRowMapper.getRestrictMappedColumns().
Exception
public void setTableQuery(String tableQuery)
throws DatabaseException
BaseRowMapperBaseRowMapper.initMapping() after setting the data.
Since a query of the form '(select ...) as t1' may not be query optimized in certain
databases, this implementation also supports a plain select statement to act as a query.
setTableQuery in class BaseRowMapper<T extends PropertyEntry>DatabaseException
public void setTableQuery(String tableQuery,
String newIdColumn)
throws DatabaseException
BaseRowMapper
setTableQuery in class BaseRowMapper<T extends PropertyEntry>DatabaseExceptionBaseRowMapper.setTableQuery(String)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||