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
ConstructorsConstructorDescriptionBatchResultBearing(ResultBearing delegate, Supplier<int[]> modifiedRowCountsSupplier) -
Method Summary
Modifier and TypeMethodDescription<R> RcollectInto(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> RcollectInto(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 aResultIterableof the given element type.Maps this result set to aResultIterableof the given element type.<T> BatchResultIterable<T> mapTo(GenericType<T> type) Maps this result set to aResultIterableof the given element type.<T> BatchResultIterable<T> mapTo(QualifiedType<T> type) Maps this result set to aResultIterableof the given qualified element type.<T> BatchResultIterable<T> Maps this result set to aResultIterableof the given element type, usingBeanMapper.mapToMap()Maps this result set to aResultIterableofMap<String,Object>.<T> BatchResultIterable<Map<String, T>> <T> BatchResultIterable<Map<String, T>> mapToMap(GenericType<T> valueType) int[]Returns the mod counts for the executedPreparedBatchNote that some database drivers might return special values likeStatement.SUCCESS_NO_INFOorStatement.EXECUTE_FAILED.<U> UreduceResultSet(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> rowReducer) Reduce the result rows using the given row reducer.<U> UreduceRows(U seed, BiFunction<U, RowView, U> accumulator) Reduce the results.<R> RscanResultSet(ResultSetScanner<R> resultSetScanner) 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:ResultBearingInvokes the mapper with a result set supplier, and returns the value returned by the mapper.- Specified by:
scanResultSetin interfaceResultBearing- Type Parameters:
R- result type returned by the mapper.- Parameters:
resultSetScanner- result set scanner- Returns:
- the value returned by the mapper.
-
mapTo
Description copied from interface:ResultBearingMaps this result set to aResultIterableof the given element type.- Specified by:
mapToin 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
ResultIterableof the given type. - See Also:
-
mapTo
Description copied from interface:ResultBearingMaps this result set to aResultIterableof the given element type.- Specified by:
mapToin 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
ResultIterableof the given type. - See Also:
-
mapTo
Description copied from interface:ResultBearingMaps this result set to aResultIterableof the given element type.- Specified by:
mapToin interfaceResultBearing- Parameters:
type- the type to map the result set rows to- Returns:
- a
ResultIterableof the given type. - See Also:
-
mapTo
Description copied from interface:ResultBearingMaps this result set to aResultIterableof the given qualified element type.- Specified by:
mapToin interfaceResultBearing- Parameters:
type- the qualified type to map the result set rows to- Returns:
- a
ResultIterableof the given type. - See Also:
-
mapToBean
Description copied from interface:ResultBearingMaps this result set to aResultIterableof the given element type, usingBeanMapper.- Specified by:
mapToBeanin 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
ResultIterableof the given type.
-
mapToMap
Description copied from interface:ResultBearingMaps this result set to aResultIterableofMap<String,Object>. Keys are column names, and values are column values.- Specified by:
mapToMapin interfaceResultBearing- Returns:
- a
ResultIterable<Map<String,Object>>.
-
mapToMap
Description copied from interface:ResultBearing- Specified by:
mapToMapin interfaceResultBearing- Type Parameters:
T- the value type- Parameters:
valueType- the class to map the resultset columns to- Returns:
- a
Mapof String and the given type. - See Also:
-
mapToMap
Description copied from interface:ResultBearing- Specified by:
mapToMapin interfaceResultBearing- Type Parameters:
T- the value type- Parameters:
valueType- the type to map the resultset columns to- Returns:
- a
Mapof String and the given type. - See Also:
-
map
Description copied from interface:ResultBearingMaps this result set to aResultIterable, using the given column mapper.- Specified by:
mapin 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
ResultIterableof type<T>.
-
map
Description copied from interface:ResultBearingMaps this result set to aResultIterable, using the given row mapper.- Specified by:
mapin interfaceResultBearing- Type Parameters:
T- the type to map the result set rows to- Parameters:
mapper- mapper used to map each row- Returns:
- a
ResultIterableof type<T>.
-
map
Description copied from interface:ResultBearingMaps this result set to aResultIterable, using the givenRowViewMapper. This overload only exists to allow RowViewMapper as the type of a lambda expression.- Specified by:
mapin interfaceResultBearing- Type Parameters:
T- the type to map the result set rows to- Parameters:
mapper- RowViewMapper used to map each row- Returns:
- a
ResultIterableof type<T>.
-
reduceRows
Description copied from interface:ResultBearingReduce the result rows using the given row reducer.- Specified by:
reduceRowsin interfaceResultBearing- Type Parameters:
C- Mutable result container typeR- Result element type- Parameters:
rowReducer- the row reducer.- Returns:
- the stream of result elements
- See Also:
-
reduceRows
Description copied from interface:ResultBearingReduce the result rows using aMap<K, V>as the result container.- Specified by:
reduceRowsin interfaceResultBearing- Type Parameters:
K- map key typeV- map value type- Parameters:
accumulator- accumulator function which gathers data from eachRowViewinto 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:ResultBearingReduce the results. Using aBiFunction<U, RowView, U>, repeatedly combine query results until only a single value remains.- Specified by:
reduceRowsin interfaceResultBearing- Type Parameters:
U- the type of the accumulator- Parameters:
seed- theUto combine with the first resultaccumulator- the function to apply repeatedly- Returns:
- the final
U
-
reduceResultSet
Description copied from interface:ResultBearingReduce the results. Using aResultSetAccumulator, repeatedly combine query results until only a single value remains.- Specified by:
reduceResultSetin interfaceResultBearing- Type Parameters:
U- the accumulator type- Parameters:
seed- theUto combine with the first resultaccumulator- the function to apply repeatedly- Returns:
- the final
U
-
collectRows
Description copied from interface:ResultBearingCollect the results using the given collector. Do not attempt to accumulate theRowViewobjects 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:
collectRowsin 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:ResultBearingCollect 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:
collectIntoin 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:ResultBearingCollect 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:
collectIntoin 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:ResultBearingCollect 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:
collectIntoin 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 executedPreparedBatchNote that some database drivers might return special values likeStatement.SUCCESS_NO_INFOorStatement.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.
-