T - the type that the jdbcMapper is mapping topublic interface JdbcMapper<T> extends org.simpleflatmapper.map.SetRowMapper<ResultSet,ResultSet,T,SQLException>, org.simpleflatmapper.map.context.MappingContextFactoryFromRows<ResultSet,ResultSet,SQLException>
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);
}
JdbcMapperFactory| Modifier and Type | Method and Description |
|---|---|
<H extends org.simpleflatmapper.util.CheckedConsumer<? super T>> |
forEach(ResultSet rs,
H handler)
Loop over the resultSet, map each row to a new newInstance of T and call back the handler.
|
Iterator<T> |
iterator(ResultSet rs) |
T |
map(ResultSet rs)
map the current row of the ResultSet to a new newInstance of T.
|
Stream<T> |
stream(ResultSet rs) |
T map(ResultSet rs) throws org.simpleflatmapper.map.MappingException
<H extends org.simpleflatmapper.util.CheckedConsumer<? super T>> H forEach(ResultSet rs, H handler) throws SQLException, org.simpleflatmapper.map.MappingException
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();
forEach in interface org.simpleflatmapper.map.EnumerableMapper<ResultSet,T,SQLException>H - the row handler typers - the resultSethandler - the handler that will get the callbackSQLException - if sql error occursorg.simpleflatmapper.map.MappingException - if an error occurs during the mappingIterator<T> iterator(ResultSet rs) throws SQLException, org.simpleflatmapper.map.MappingException
iterator in interface org.simpleflatmapper.map.EnumerableMapper<ResultSet,T,SQLException>rs - the result setSQLException - if sql error occursorg.simpleflatmapper.map.MappingException - if an error occurs during the mappingStream<T> stream(ResultSet rs) throws SQLException, org.simpleflatmapper.map.MappingException
stream in interface org.simpleflatmapper.map.EnumerableMapper<ResultSet,T,SQLException>rs - the result setSQLException - if sql error occursorg.simpleflatmapper.map.MappingException - if an error occurs during the mappingCopyright © 2020. All rights reserved.