Holger's Java API

## com.antelmann.sql
Class BeanMapper<T extends DBEntry>

    java.lang.Object
      com.antelmann.sql.BaseRowMapper<T>
          com.antelmann.sql.BeanMapper<T>

All Implemented Interfaces:
  TransactionRequired, MappingInfo, ObjectRowMapper<T>, Converter<RowItem,T>

    public class BeanMapper<T extends DBEntry>

extends BaseRowMapper<T>

a specialized mapper that allows to map columns to property names based on Bean patterns.

Since:
  31.12.2014, 23:01:29
Author:
  holger

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
`BeanMapper(Database<Connection> db, MappingInfo mi, IDFactory idFactory, Class<T> type, Object... topics)`
`BeanMapper(Database<Connection> db, String tableName, String idColumn, String displayColumn, IDFactory idFactory, Class<T> type, String query)`

Method Summary
`void` `addBeanProperty(String column, Method setterMethod)`
`void` `addBeanProperty(String column, String propertyName)` allows to add a column mapping by specifying the property name as a String.
`protected Map<String,Object>` `generateRowProperties(T entry)` generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row.
`T` `instantiate(RowItem row)` instantiates the DBEntry based on the properties in the given row.
`protected T` `mapBeans(RowItem row, T entry)`
`protected HashMap<String,Object>` `mapBeans(T entry, HashMap<String,Object> map)`

Methods inherited from class com.antelmann.sql.BaseRowMapper

`addColumnsForTopic, applyFromMapping, checkExistence, convert, convertBack, convertTopicFilter, emptyStringsToNull, extractReference, extractStub, extractStub, generateNewID, getAll, getColumnDisplayMapping, getColumnNames, getColumnsForTopic, getColumnSize, getConnection, getConnectionHelper, getDisplayColumn, getDisplayNameForColumn, getEntryClass, getEntryClassMapper, getIDColumn, getIDFactory, getMappedValue, getMappingForTopic, getNextIntID, getNextIntIDFactory, getNextIntIDFactory, getPreStoreFilter, getReadOnlyColumns, getRestrictMappedColumns, getResultSet, getSQLTypeforColumn, getStubColumns, getStubQuery, getStubResultSet, getSupportedTopicColumns, getTableColumnNames, getTableName, getTableQuery, getTableQueryForComboFilter, getTransactionCounter, getUniqueRandomString, handleAfterStore, initMapping, isMappedTopic, isTranslate, javaToSql, javaToSql, lockTable, mapReference, mapReference, mapToRow, removeColumnTopic, setColumnsForTopic, setDisplayColumn, setEntryClass, setEntryClassMapper, setIDFactory, setMappedValue, setNextIntIdAsFactory, setPreStoreFilter, setReadOnlyColumns, setRestrictedMappedColumns, setStubQuery, setTableQuery, setTableQuery, setTopic, setTranslate, sqlToJava, toSQLMap, verifyBeforeDelete, verifyBeforeStore`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BeanMapper

    public BeanMapper(Database<Connection> db,
                      MappingInfo mi,
                      IDFactory idFactory,
                      Class<T> type,
                      Object... topics)
               throws DatabaseException

Throws:
  `DatabaseException`

### BeanMapper

    public BeanMapper(Database<Connection> db,
                      String tableName,
                      String idColumn,
                      String displayColumn,
                      IDFactory idFactory,
                      Class<T> type,
                      String query)
               throws DatabaseException

Throws:
  `DatabaseException`

Method Detail

### addBeanProperty

    public void addBeanProperty(String column,
                                Method setterMethod)

### addBeanProperty

    public void addBeanProperty(String column,
                                String propertyName)

  allows to add a column mapping by specifying the property name as a String. Note that polymorphism provides problems in this context! In this case, avoid using this method but use the more explicit `addBeanProperty(String, Method)`.

  See Also:
    `addBeanProperty(String, Method)`

### instantiate

    public T instantiate(RowItem row)
                                  throws Exception

  Description copied from interface: `ObjectRowMapper`
  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 `ObjectRowMapper.getRestrictMappedColumns()`.

  Throws:
    `Exception`

### mapBeans

    protected T mapBeans(RowItem row,
                         T entry)
                                  throws Exception

  Throws:
    `Exception`

### generateRowProperties

    protected Map<String,Object> generateRowProperties(T entry)
                                                throws WrongDataException

  Description copied from class: `BaseRowMapper`
  generates a map that contains all columns mapped to their values, so that the map can be used to store the object into a row. The ID column and the corresponding ID should not be put in there, as this will happen automatically later.

  Specified by:
    `generateRowProperties` in class `BaseRowMapper<T extends DBEntry>`
  Throws:
    `WrongDataException`

### mapBeans

    protected HashMap<String,Object> mapBeans(T entry,
                                              HashMap<String,Object> map)
                                       throws WrongDataException

  Throws:
    `WrongDataException`

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