T - the type that the mapper is mapping topublic interface JdbcMapper<T> extends Mapper<ResultSet,T>
ResultSet to an object of the specified type T
JdbcMapper are instantiable via JdbcMapperFactory.
JdbcMapper<MyClass> mapper = JdbcMapperFactory.newInstance().newMapper(MyClass.class);
...
try (ResultSet rs : ps.executeQuery()){
mapper.stream(rs).forEach(System.out::println);
}
JdbcMapperFactory| Modifier and Type | Method and Description |
|---|---|
<H extends RowHandler<? super T>> |
forEach(ResultSet rs,
H handle)
Loop over the resultSet, map each row to a new instance of T and call back the handler
|
Iterator<T> |
iterate(ResultSet rs)
Deprecated.
|
Iterator<T> |
iterator(ResultSet rs) |
Stream<T> |
stream(ResultSet rs) |
map, map, newMappingContextmapTo<H extends RowHandler<? super T>> H forEach(ResultSet rs, H handle) throws SQLException, MappingException
The method will return the handler passed as an argument so you can easily chain the calls like
List<T> list = mapper.forEach(rs, new ListHandler<T>()).getList();
H - the row handler typers - the resultSethandle - the handler that will get the callbackSQLException - if sql error occursMappingException - if an error occurs during the mappingIterator<T> iterator(ResultSet rs) throws SQLException, MappingException
rs - the result setSQLException - if sql error occursMappingException - if an error occurs during the mapping@Deprecated Iterator<T> iterate(ResultSet rs) throws SQLException, MappingException
SQLExceptionMappingExceptionStream<T> stream(ResultSet rs) throws SQLException, MappingException
rs - the result setSQLException - if sql error occursMappingException - if an error occurs during the mappingCopyright © 2015. All rights reserved.