public interface ResultBearing
ResultSet by mapping to Java types.| Modifier and Type | Method and Description |
|---|---|
default <R> R |
collectInto(Class<R> containerType)
Collect the results into a container of the given type.
|
default <R> R |
collectInto(GenericType<R> containerType)
Collect the results into a container of the given generic type.
|
default Object |
collectInto(Type containerType)
Collect the results into a container of the given type.
|
default <T> ResultIterable<T> |
map(ColumnMapper<T> mapper)
Maps this result set to a
ResultIterable, using the given column mapper. |
default <T> ResultIterable<T> |
map(RowMapper<T> mapper)
Maps this result set to a
ResultIterable, using the given row mapper. |
default <T> ResultIterable<T> |
mapTo(Class<T> type)
Maps this result set to a
ResultIterable of the given element type. |
default <T> ResultIterable<T> |
mapTo(GenericType<T> type)
Maps this result set to a
ResultIterable of the given element type. |
default ResultIterable<?> |
mapTo(Type type)
Maps this result set to a
ResultIterable of the given element type. |
default <T> ResultIterable<T> |
mapToBean(Class<T> type)
Maps this result set to a
ResultIterable of the given element type, using BeanMapper. |
default ResultIterable<Map<String,Object>> |
mapToMap()
Maps this result set to a
ResultIterable of Map<String,Object>. |
static ResultBearing |
of(Supplier<ResultSet> resultSetSupplier,
StatementContext ctx)
Returns a ResultBearing backed by the given result set supplier and context.
|
default <U> U |
reduceResultSet(U seed,
ResultSetAccumulator<U> accumulator)
Reduce the results.
|
default <U> U |
reduceRows(U seed,
BiFunction<U,RowView,U> accumulator)
Reduce the results.
|
<R> R |
scanResultSet(ResultSetScanner<R> mapper)
Invokes the mapper with a result set supplier, and returns the value returned by the mapper.
|
default <R> R collectInto(Class<R> containerType)
This method is equivalent to ResultBearing.mapTo(elementType).collect(containerCollector).
R - the result container typecontainerType - the container type into which results will be collecteddefault <R> R collectInto(GenericType<R> containerType)
This method is equivalent to ResultBearing.mapTo(elementType).collect(containerCollector).
Example:
Map<Long, User> usersById = handle.createQuery("select * from user")
.configure(MapEntryMappers.class, cfg -> cfg.setKeyColumn("id"))
.collectInto(new GenericType<Map<Long, User>>() {});
R - the result container typecontainerType - the container type into which results will be collecteddefault Object collectInto(Type containerType)
This method is equivalent to ResultBearing.mapTo(elementType).collect(containerCollector).
containerType - the container type into which results will be collecteddefault <T> ResultIterable<T> map(ColumnMapper<T> mapper)
ResultIterable, using the given column mapper.T - the type to map the result set rows tomapper - column mapper used to map the first column of each rowResultIterable of type <T>.default <T> ResultIterable<T> map(RowMapper<T> mapper)
ResultIterable, using the given row mapper.T - the type to map the result set rows tomapper - mapper used to map each rowResultIterable of type <T>.default <T> ResultIterable<T> mapTo(Class<T> type)
ResultIterable of the given element type.T - the type to map the result set rows totype - the type to map the result set rows toResultIterable of the given type.Configurable.registerRowMapper(RowMapper),
Configurable.registerRowMapper(RowMapperFactory),
Configurable.registerColumnMapper(ColumnMapperFactory),
Configurable.registerColumnMapper(ColumnMapper)default <T> ResultIterable<T> mapTo(GenericType<T> type)
ResultIterable of the given element type.T - the type to map the result set rows totype - the type to map the result set rows toResultIterable of the given type.Configurable.registerRowMapper(RowMapper),
Configurable.registerRowMapper(RowMapperFactory),
Configurable.registerColumnMapper(ColumnMapperFactory),
Configurable.registerColumnMapper(ColumnMapper)default ResultIterable<?> mapTo(Type type)
ResultIterable of the given element type.type - the type to map the result set rows toResultIterable of the given type.Configurable.registerRowMapper(RowMapper),
Configurable.registerRowMapper(RowMapperFactory),
Configurable.registerColumnMapper(ColumnMapperFactory),
Configurable.registerColumnMapper(ColumnMapper)default <T> ResultIterable<T> mapToBean(Class<T> type)
ResultIterable of the given element type, using BeanMapper.T - the bean type to map the result set rows totype - the bean type to map the result set rows toResultIterable of the given type.default ResultIterable<Map<String,Object>> mapToMap()
ResultIterable of Map<String,Object>. Keys are column names, and
values are column values.ResultIterable<Map<String,Object>>.static ResultBearing of(Supplier<ResultSet> resultSetSupplier, StatementContext ctx)
resultSetSupplier - result set supplierctx - the statement contextdefault <U> U reduceResultSet(U seed,
ResultSetAccumulator<U> accumulator)
ResultSetAccumulator, repeatedly
combine query results until only a single value remains.U - the accumulator typeseed - the U to combine with the first resultaccumulator - the function to apply repeatedlyUdefault <U> U reduceRows(U seed,
BiFunction<U,RowView,U> accumulator)
BiFunction<U, RowView, U>, repeatedly
combine query results until only a single value remains.U - the type of the accumulatorseed - the U to combine with the first resultaccumulator - the function to apply repeatedlyU<R> R scanResultSet(ResultSetScanner<R> mapper)
R - result type returned by the mapper.mapper - result set mapperCopyright © 2017. All rights reserved.