Interface ResultBearing

    • Method Detail

      • of

        static ResultBearing of​(java.util.function.Supplier<java.sql.ResultSet> resultSetSupplier,
                                StatementContext ctx)
        Returns a ResultBearing backed by the given result set supplier and context.
        Parameters:
        resultSetSupplier - result set supplier
        ctx - the statement context
        Returns:
        a ResultBearing
      • scanResultSet

        <R> R scanResultSet​(ResultSetScanner<R> resultSetScanner)
        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.
      • mapToBean

        default <T> ResultIterable<T> mapToBean​(java.lang.Class<T> type)
        Maps this result set to a ResultIterable of the given element type, using BeanMapper.
        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

        default <T> ResultIterable<java.util.Map<java.lang.String,​T>> mapToMap​(java.lang.Class<T> valueType)
        Maps this result set to a Map of String and the given value class.
        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:
        Configurable.registerColumnMapper(ColumnMapper)
      • mapToMap

        default <T> ResultIterable<java.util.Map<java.lang.String,​T>> mapToMap​(GenericType<T> valueType)
        Maps this result set to a Map of String and the given value type.
        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:
        Configurable.registerColumnMapper(ColumnMapper)
      • map

        default <T> ResultIterable<T> map​(ColumnMapper<T> mapper)
        Maps this result set to a ResultIterable, 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

        default <T> ResultIterable<T> map​(RowMapper<T> mapper)
        Maps this result set to a ResultIterable, 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

        default <T> ResultIterable<T> map​(RowViewMapper<T> mapper)
        Maps this result set to a ResultIterable, using the given RowViewMapper. 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

        default <C,​R> java.util.stream.Stream<R> reduceRows​(RowReducer<C,​R> rowReducer)
        Reduce the result rows using the given row reducer.
        Type Parameters:
        C - Mutable result container type
        R - Result element type
        Parameters:
        rowReducer - the row reducer.
        Returns:
        the stream of result elements
        See Also:
        RowReducer
      • reduceRows

        default <K,​V> java.util.stream.Stream<V> reduceRows​(java.util.function.BiConsumer<java.util.Map<K,​V>,​RowView> accumulator)
        Reduce the result rows using a Map<K, V> as the result container.
        Type Parameters:
        K - map key type
        V - map value type
        Parameters:
        accumulator - accumulator function which gathers data from each RowView into the result map.
        Returns:
        the stream of elements in the container's Map.values() collection, in the order they were inserted.
      • reduceRows

        default <U> U reduceRows​(U seed,
                                 java.util.function.BiFunction<U,​RowView,​U> accumulator)
        Reduce the results. Using a BiFunction<U, RowView, U>, repeatedly combine query results until only a single value remains.
        Type Parameters:
        U - the type of the accumulator
        Parameters:
        seed - the U to combine with the first result
        accumulator - the function to apply repeatedly
        Returns:
        the final U
      • reduceResultSet

        default <U> U reduceResultSet​(U seed,
                                      ResultSetAccumulator<U> accumulator)
        Reduce the results. Using a ResultSetAccumulator, repeatedly combine query results until only a single value remains.
        Type Parameters:
        U - the accumulator type
        Parameters:
        seed - the U to combine with the first result
        accumulator - the function to apply repeatedly
        Returns:
        the final U
      • collectRows

        default <A,​R> R collectRows​(java.util.stream.Collector<RowView,​A,​R> collector)
        Collect the results using the given collector. Do not attempt to accumulate the 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().
        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

        default <R> R collectInto​(java.lang.Class<R> containerType)
        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

        default <R> R collectInto​(GenericType<R> containerType)
        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

        default java.lang.Object collectInto​(java.lang.reflect.Type containerType)
        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