- Type Parameters:
T- the type that the jdbcMapper is mapping to
- All Superinterfaces:
org.simpleflatmapper.map.ContextualSourceMapper<ResultSet,,T> org.simpleflatmapper.map.EnumerableMapper<ResultSet,,T, SQLException> org.simpleflatmapper.map.context.MappingContextFactoryFromRows<ResultSet,,ResultSet, SQLException> org.simpleflatmapper.map.SetRowMapper<ResultSet,,ResultSet, T, SQLException> org.simpleflatmapper.map.SourceMapper<ResultSet,T>
- All Known Subinterfaces:
DynamicJdbcMapper<T>
- All Known Implementing Classes:
JdbcMapperFactory.DynamicJdbcSetRowMapper
public interface JdbcMapper<T>
extends org.simpleflatmapper.map.SetRowMapper<ResultSet,ResultSet,T,SQLException>, org.simpleflatmapper.map.context.MappingContextFactoryFromRows<ResultSet,ResultSet,SQLException>
JdbcMapper will map from a
ResultSet to an object of the specified type T
JdbcMapper are instantiable via JdbcMapperFactory.
JdbcMapper<MyClass> jdbcMapper = JdbcMapperFactory.newInstance().newMapper(MyClass.class);
...
try (ResultSet rs : ps.executeQuery()){
jdbcMapper.stream(rs).forEach(System.out::println);
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescription<H extends org.simpleflatmapper.util.CheckedConsumer<? super T>>
HLoop over the resultSet, map each row to a new newInstance of T and call back the handler.map the current row of the ResultSet to a new newInstance of T.Methods inherited from interface org.simpleflatmapper.map.EnumerableMapper
enumerateMethods inherited from interface org.simpleflatmapper.map.context.MappingContextFactoryFromRows
newMappingContextMethods inherited from interface org.simpleflatmapper.map.SourceMapper
map
-
Method Details
-
map
map the current row of the ResultSet to a new newInstance of T. This method does not manage the iteration of the ResultSet and will only map the current row. No join aggregation will be performed. -
forEach
<H extends org.simpleflatmapper.util.CheckedConsumer<? super T>> H forEach(ResultSet rs, H handler) throws SQLException, org.simpleflatmapper.map.MappingException Loop over the resultSet, map each row to a new newInstance of T and call back the handler.The method will return the handler passed as an argument so you can easily chain the calls like
List<T> list = jdbcMapper.forEach(rs, new ListHandler<T>()).getList();- Specified by:
forEachin interfaceorg.simpleflatmapper.map.EnumerableMapper<ResultSet,T, SQLException> - Type Parameters:
H- the row handler type- Parameters:
rs- the resultSethandler- the handler that will get the callback- Returns:
- the handler passed in
- Throws:
SQLException- if sql error occursorg.simpleflatmapper.map.MappingException- if an error occurs during the mapping
-
iterator
- Specified by:
iteratorin interfaceorg.simpleflatmapper.map.EnumerableMapper<ResultSet,T, SQLException> - Parameters:
rs- the result set- Returns:
- an iterator that will return a map object for each row of the result set.
- Throws:
SQLException- if sql error occursorg.simpleflatmapper.map.MappingException- if an error occurs during the mapping
-
stream
- Specified by:
streamin interfaceorg.simpleflatmapper.map.EnumerableMapper<ResultSet,T, SQLException> - Parameters:
rs- the result set- Returns:
- a stream that will contain a map object for each row of the result set.
- Throws:
SQLException- if sql error occursorg.simpleflatmapper.map.MappingException- if an error occurs during the mapping
-