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 <A,R> R |
collectRows(Collector<RowView,A,R> collector)
Collect the results using the given collector.
|
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> |
map(RowViewMapper<T> mapper)
Maps this result set to a
ResultIterable, using the given RowViewMapper. |
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 <T> ResultIterable<T> |
mapTo(QualifiedType<T> type)
Maps this result set to a
ResultIterable of the given qualified 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>. |
default <T> ResultIterable<Map<String,T>> |
mapToMap(Class<T> valueType)
|
default <T> ResultIterable<Map<String,T>> |
mapToMap(GenericType<T> valueType)
|
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 <K,V> Stream<V> |
reduceRows(BiConsumer<Map<K,V>,RowView> accumulator)
Reduce the result rows using a
Map<K, V> as the
result container. |
default <C,R> Stream<R> |
reduceRows(RowReducer<C,R> reducer)
Reduce the result rows using the given row reducer.
|
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 <A,R> R collectRows(Collector<RowView,A,R> collector)
RowView objects into the result--they are only valid within the
Collector.accumulator() function. Instead, extract mapped types from the
RowView by calling RowView.getRow() or RowView.getColumn().A - the mutable accumulator type used by the collector.R - the result type returned by the collector.collector - the collector to collect the result rows.default <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> map(RowViewMapper<T> mapper)
ResultIterable, using the given RowViewMapper.
This overload only exists to allow RowViewMapper as the type of a lambda expression.T - the type to map the result set rows tomapper - RowViewMapper 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(org.jdbi.v3.core.mapper.RowMapperFactory),
Configurable.registerColumnMapper(org.jdbi.v3.core.mapper.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(org.jdbi.v3.core.mapper.RowMapperFactory),
Configurable.registerColumnMapper(org.jdbi.v3.core.mapper.ColumnMapperFactory),
Configurable.registerColumnMapper(ColumnMapper)@Beta default <T> ResultIterable<T> mapTo(QualifiedType<T> type)
ResultIterable of the given qualified element type.type - the qualified type to map the result set rows toResultIterable of the given type.Configurable.registerRowMapper(RowMapper),
Configurable.registerRowMapper(org.jdbi.v3.core.mapper.RowMapperFactory),
Configurable.registerColumnMapper(org.jdbi.v3.core.mapper.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(org.jdbi.v3.core.mapper.RowMapperFactory),
Configurable.registerColumnMapper(org.jdbi.v3.core.mapper.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>>.@Beta default <T> ResultIterable<Map<String,T>> mapToMap(Class<T> valueType)
T - the value typevalueType - the class to map the resultset columns toMap of String and the given type.Configurable.registerColumnMapper(ColumnMapper)@Beta default <T> ResultIterable<Map<String,T>> mapToMap(GenericType<T> valueType)
T - the value typevalueType - the type to map the resultset columns toMap of String and the given type.Configurable.registerColumnMapper(ColumnMapper)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 <K,V> Stream<V> reduceRows(BiConsumer<Map<K,V>,RowView> accumulator)
Map<K, V> as the
result container.K - map key typeV - map value typeaccumulator - accumulator function which gathers data from each
RowView into the result map.Map.values()
collection, in the order they were inserted.default <C,R> Stream<R> reduceRows(RowReducer<C,R> reducer)
C - Mutable result container typeR - Result element typereducer - the row reducer.RowReducerdefault <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 scannerCopyright © 2019. All rights reserved.