Package org.jdbi.v3.core.result
Interface ResultBearing
- All Known Implementing Classes:
BatchResultBearing
,MetaData
,PreparedBatch
,Query
public interface ResultBearing
Provides access to the contents of a
ResultSet
by mapping to Java types.-
Method Summary
Modifier and TypeMethodDescriptiondefault <R> R
collectInto
(Class<R> containerType) Collect the results into a container of the given type.default Object
collectInto
(Type 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 <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 aResultIterable
, using the given column mapper.default <T> ResultIterable
<T> Maps this result set to aResultIterable
, using the given row mapper.default <T> ResultIterable
<T> map
(RowViewMapper<T> mapper) Maps this result set to aResultIterable
, using the givenRowViewMapper
.default <T> ResultIterable
<T> Maps this result set to aResultIterable
of the given element type.default ResultIterable
<?> Maps this result set to aResultIterable
of the given element type.default <T> ResultIterable
<T> mapTo
(GenericType<T> type) Maps this result set to aResultIterable
of the given element type.default <T> ResultIterable
<T> mapTo
(QualifiedType<T> type) Maps this result set to aResultIterable
of the given qualified element type.default <T> ResultIterable
<T> Maps this result set to aResultIterable
of the given element type, usingBeanMapper
.default ResultIterable
<Map<String, Object>> mapToMap()
Maps this result set to aResultIterable
ofMap<String,Object>
.default <T> ResultIterable
<Map<String, T>> 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 aMap<K, V>
as the result container.default <C,
R> Stream <R> reduceRows
(RowReducer<C, R> rowReducer) 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> resultSetScanner) Invokes the mapper with a result set supplier, and returns the value returned by the mapper.
-
Method Details
-
of
Returns a ResultBearing backed by the given result set supplier and context.- Parameters:
resultSetSupplier
- result set supplierctx
- the statement context- Returns:
- a ResultBearing
-
scanResultSet
Invokes the mapper with a result set supplier, and returns the value returned by the mapper.- Type Parameters:
R
- result type returned by the mapper.- Parameters:
resultSetScanner
- result set scanner- Returns:
- the value returned by the mapper.
-
mapTo
Maps this result set to aResultIterable
of the given element type.- Type Parameters:
T
- the type to map the result set rows to- Parameters:
type
- the type to map the result set rows to- Returns:
- a
ResultIterable
of the given type. - See Also:
-
mapTo
Maps this result set to aResultIterable
of the given element type.- Type Parameters:
T
- the type to map the result set rows to- Parameters:
type
- the type to map the result set rows to- Returns:
- a
ResultIterable
of the given type. - See Also:
-
mapTo
Maps this result set to aResultIterable
of the given element type.- Parameters:
type
- the type to map the result set rows to- Returns:
- a
ResultIterable
of the given type. - See Also:
-
mapTo
Maps this result set to aResultIterable
of the given qualified element type.- Parameters:
type
- the qualified type to map the result set rows to- Returns:
- a
ResultIterable
of the given type. - See Also:
-
mapToBean
Maps this result set to aResultIterable
of the given element type, usingBeanMapper
.- Type Parameters:
T
- the bean type to map the result set rows to- Parameters:
type
- the bean type to map the result set rows to- Returns:
- a
ResultIterable
of the given type.
-
mapToMap
Maps this result set to aResultIterable
ofMap<String,Object>
. Keys are column names, and values are column values.- Returns:
- a
ResultIterable<Map<String,Object>>
.
-
mapToMap
-
mapToMap
- Type Parameters:
T
- the value type- Parameters:
valueType
- the type to map the resultset columns to- Returns:
- a
Map
of String and the given type. - See Also:
-
map
Maps this result set to aResultIterable
, using the given column mapper.- Type Parameters:
T
- the type to map the result set rows to- Parameters:
mapper
- column mapper used to map the first column of each row- Returns:
- a
ResultIterable
of type<T>
.
-
map
Maps this result set to aResultIterable
, using the given row mapper.- Type Parameters:
T
- the type to map the result set rows to- Parameters:
mapper
- mapper used to map each row- Returns:
- a
ResultIterable
of type<T>
.
-
map
Maps this result set to aResultIterable
, using the givenRowViewMapper
. This overload only exists to allow RowViewMapper as the type of a lambda expression.- Type Parameters:
T
- the type to map the result set rows to- Parameters:
mapper
- RowViewMapper used to map each row- Returns:
- a
ResultIterable
of type<T>
.
-
reduceRows
Reduce the result rows using the given row reducer.- Type Parameters:
C
- Mutable result container typeR
- Result element type- Parameters:
rowReducer
- the row reducer.- Returns:
- the stream of result elements
- See Also:
-
reduceRows
Reduce the result rows using aMap<K, V>
as the result container.- Type Parameters:
K
- map key typeV
- map value type- Parameters:
accumulator
- accumulator function which gathers data from eachRowView
into the result map.- Returns:
- the stream of elements in the container's
Map.values()
collection, in the order they were inserted.
-
reduceRows
Reduce the results. Using aBiFunction<U, RowView, U>
, repeatedly combine query results until only a single value remains.- Type Parameters:
U
- the type of the accumulator- Parameters:
seed
- theU
to combine with the first resultaccumulator
- the function to apply repeatedly- Returns:
- the final
U
-
reduceResultSet
Reduce the results. Using aResultSetAccumulator
, repeatedly combine query results until only a single value remains.- Type Parameters:
U
- the accumulator type- Parameters:
seed
- theU
to combine with the first resultaccumulator
- the function to apply repeatedly- Returns:
- the final
U
-
collectRows
Collect the results using the given collector. Do not attempt to accumulate theRowView
objects into the result--they are only valid within theCollector.accumulator()
function. Instead, extract mapped types from the RowView by callingRowView.getRow()
orRowView.getColumn()
.- Type Parameters:
A
- the mutable accumulator type used by the collector.R
- the result type returned by the collector.- Parameters:
collector
- the collector to collect the result rows.- Returns:
- the result of the collection
-
collectInto
Collect the results into a container of the given type. A collector must be registered for the container type, which knows the element type for the container. A mapper must be registered for the element type.This method is equivalent to
ResultBearing.mapTo(elementType).collect(containerCollector)
.- Type Parameters:
R
- the result container type- Parameters:
containerType
- the container type into which results will be collected- Returns:
- a container into which result rows have been collected
-
collectInto
Collect the results into a container of the given generic type. A collector must be registered for the container type, which knows the element type for the container. A mapper must be registered for the element type.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>>() {});
- Type Parameters:
R
- the result container type- Parameters:
containerType
- the container type into which results will be collected- Returns:
- a container into which result rows have been collected
-
collectInto
Collect the results into a container of the given type. A collector must be registered for the container type, which knows the element type for the container. A mapper must be registered for the element type.This method is equivalent to
ResultBearing.mapTo(elementType).collect(containerCollector)
.- Parameters:
containerType
- the container type into which results will be collected- Returns:
- a container into which result rows have been collected
-