public class BeanMapper<T> extends Object implements RowMapper<T>
| Constructor and Description |
|---|
BeanMapper(Class<T> type) |
BeanMapper(Class<T> type,
String prefix) |
| Modifier and Type | Method and Description |
|---|---|
T |
map(ResultSet rs,
StatementContext ctx)
Map the row the result set is at when passed in.
|
static RowMapperFactory |
of(Class<?> type)
Returns a mapper factory that maps to the given bean class
|
static RowMapperFactory |
of(Class<?> type,
String prefix)
Returns a mapper factory that maps to the given bean class
|
RowMapper<T> |
specialize(ResultSet rs,
StatementContext ctx)
Returns a specialized row mapper, optimized for the given result set.
|
public T map(ResultSet rs, StatementContext ctx) throws SQLException
RowMappermap in interface RowMapper<T>rs - the result set being iteratedctx - the statement contextSQLException - if anything goes wrong go ahead and let this percolate, jDBI will handle itpublic static RowMapperFactory of(Class<?> type)
type - the mapped classpublic static RowMapperFactory of(Class<?> type, String prefix)
type - the mapped classprefix - the column name prefix for each mapped bean propertypublic RowMapper<T> specialize(ResultSet rs, StatementContext ctx) throws SQLException
RowMapperBefore mapping the result set from a SQL statement, JDBI will first call this method to obtain a specialized instance. The returned mapper will then be used to map the result set rows, and discarded.
Implementing this method is optional; the default implementation returns this. Implementors might choose
to override this method to improve performance, e.g. by matching up column names to properties once for the
entire result set, rather than repeating the process for every row.
specialize in interface RowMapper<T>rs - the result set to specialize overctx - the statement context to specialize overSQLException - if anything goes wrong go ahead and let this percolate, jDBI will handle itfor an example of specialization.Copyright © 2017. All rights reserved.