public class BeanMapper<T> extends Object implements RowMapper<T>
| Modifier and Type | Method and Description |
|---|---|
static RowMapperFactory |
factory(Class<?> type)
Returns a mapper factory that maps to the given bean class
|
static RowMapperFactory |
factory(Class<?> type,
String prefix)
Returns a mapper factory that maps to the given bean class
|
T |
map(ResultSet rs,
StatementContext ctx)
Map the row the result set is at when passed in.
|
static <T> RowMapper<T> |
of(Class<T> type)
Returns a mapper for the given bean class
|
static <T> RowMapper<T> |
of(Class<T> type,
String prefix)
Returns a mapper for the given bean class
|
RowMapper<T> |
specialize(ResultSet rs,
StatementContext ctx)
Returns a specialized row mapper, optimized for the given result set.
|
public static RowMapperFactory factory(Class<?> type)
type - the mapped classpublic static RowMapperFactory factory(Class<?> type, String prefix)
type - the mapped classprefix - the column name prefix for each mapped bean propertypublic 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 <T> RowMapper<T> of(Class<T> type)
T - the type to find the mapper fortype - the mapped classpublic static <T> RowMapper<T> of(Class<T> type, String prefix)
T - the type to find the mapper fortype - 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.