Package org.jdbi.v3.core.result
Class BatchResultBearing
java.lang.Object
org.jdbi.v3.core.result.BatchResultBearing
- All Implemented Interfaces:
ResultBearing
Extends the
ResultBearing
class to provide access to the per-batch row modification counts.-
Constructor Summary
ConstructorDescriptionBatchResultBearing
(ResultBearing delegate, Supplier<int[]> modifiedRowCountsSupplier) -
Method Summary
Modifier and TypeMethodDescription<R> R
collectInto
(Class<R> containerType) Collect the results into a container of the given type.collectInto
(Type containerType) Collect the results into a container of the given type.<R> R
collectInto
(GenericType<R> containerType) Collect the results into a container of the given generic type.<A,
R> R collectRows
(Collector<RowView, A, R> collector) Collect the results using the given collector.<T> BatchResultIterable<T>
map
(ColumnMapper<T> mapper) Maps this result set to aResultIterable
, using the given column mapper.<T> BatchResultIterable<T>
Maps this result set to aResultIterable
, using the given row mapper.<T> BatchResultIterable<T>
map
(RowViewMapper<T> mapper) Maps this result set to aResultIterable
, using the givenRowViewMapper
.<T> BatchResultIterable<T>
Maps this result set to aResultIterable
of the given element type.Maps this result set to aResultIterable
of the given element type.<T> BatchResultIterable<T>
mapTo
(GenericType<T> type) Maps this result set to aResultIterable
of the given element type.<T> BatchResultIterable<T>
mapTo
(QualifiedType<T> type) Maps this result set to aResultIterable
of the given qualified element type.<T> BatchResultIterable<T>
Maps this result set to aResultIterable
of the given element type, usingBeanMapper
.mapToMap()
Maps this result set to aResultIterable
ofMap<String,Object>
.<T> BatchResultIterable<Map<String,
T>> <T> BatchResultIterable<Map<String,
T>> mapToMap
(GenericType<T> valueType) int[]
Returns the mod counts for the executedPreparedBatch
Note that some database drivers might return special values likeStatement.SUCCESS_NO_INFO
orStatement.EXECUTE_FAILED
.<U> U
reduceResultSet
(U seed, ResultSetAccumulator<U> accumulator) Reduce the results.<K,
V> Stream<V> reduceRows
(BiConsumer<Map<K, V>, RowView> accumulator) Reduce the result rows using aMap<K, V>
as the result container.<C,
R> Stream<R> reduceRows
(RowReducer<C, R> reducer) Reduce the result rows using the given row reducer.<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.
-
Constructor Details
-
BatchResultBearing
-
-
Method Details
-
scanResultSet
Description copied from interface:ResultBearing
Invokes the mapper with a result set supplier, and returns the value returned by the mapper.- Specified by:
scanResultSet
in interfaceResultBearing
- Type Parameters:
R
- result type returned by the mapper.- Parameters:
mapper
- result set scanner- Returns:
- the value returned by the mapper.
-
mapTo
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
of the given element type.- Specified by:
mapTo
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
of the given element type.- Specified by:
mapTo
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
of the given element type.- Specified by:
mapTo
in interfaceResultBearing
- Parameters:
type
- the type to map the result set rows to- Returns:
- a
ResultIterable
of the given type. - See Also:
-
mapTo
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
of the given qualified element type.- Specified by:
mapTo
in interfaceResultBearing
- Parameters:
type
- the qualified type to map the result set rows to- Returns:
- a
ResultIterable
of the given type. - See Also:
-
mapToBean
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
of the given element type, usingBeanMapper
.- Specified by:
mapToBean
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
ofMap<String,Object>
. Keys are column names, and values are column values.- Specified by:
mapToMap
in interfaceResultBearing
- Returns:
- a
ResultIterable<Map<String,Object>>
.
-
mapToMap
Description copied from interface:ResultBearing
- Specified by:
mapToMap
in interfaceResultBearing
- Type Parameters:
T
- the value type- Parameters:
valueType
- the class to map the resultset columns to- Returns:
- a
Map
of String and the given type. - See Also:
-
mapToMap
Description copied from interface:ResultBearing
- Specified by:
mapToMap
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
, using the given column mapper.- Specified by:
map
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
, using the given row mapper.- Specified by:
map
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Maps this result set to aResultIterable
, using the givenRowViewMapper
. This overload only exists to allow RowViewMapper as the type of a lambda expression.- Specified by:
map
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Reduce the result rows using the given row reducer.- Specified by:
reduceRows
in interfaceResultBearing
- Type Parameters:
C
- Mutable result container typeR
- Result element type- Parameters:
reducer
- the row reducer.- Returns:
- the stream of result elements
- See Also:
-
reduceRows
Description copied from interface:ResultBearing
Reduce the result rows using aMap<K, V>
as the result container.- Specified by:
reduceRows
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Reduce the results. Using aBiFunction<U, RowView, U>
, repeatedly combine query results until only a single value remains.- Specified by:
reduceRows
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
Reduce the results. Using aResultSetAccumulator
, repeatedly combine query results until only a single value remains.- Specified by:
reduceResultSet
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
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()
.- Specified by:
collectRows
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
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)
.- Specified by:
collectInto
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
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>>() {});
- Specified by:
collectInto
in interfaceResultBearing
- 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
Description copied from interface:ResultBearing
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)
.- Specified by:
collectInto
in interfaceResultBearing
- Parameters:
containerType
- the container type into which results will be collected- Returns:
- a container into which result rows have been collected
-
modifiedRowCounts
public int[] modifiedRowCounts()Returns the mod counts for the executedPreparedBatch
Note that some database drivers might return special values likeStatement.SUCCESS_NO_INFO
orStatement.EXECUTE_FAILED
.
Note that the result is only available after the statement was executed (eg. by calling map()). Calling this method before execution will return an empty array.- Returns:
- the number of modified rows per batch part for the executed
PreparedBatch
.
-