Class ResultSetEnumerable<T>

    • Field Detail

      • dataSource

        private final javax.sql.DataSource dataSource
      • sql

        private final java.lang.String sql
      • rowBuilderFactory

        private final Function1<java.sql.ResultSet,​Function0<T>> rowBuilderFactory
      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • queryStart

        private java.lang.Long queryStart
      • timeout

        private long timeout
      • timeoutSetFailed

        private boolean timeoutSetFailed
      • AUTO_ROW_BUILDER_FACTORY

        private static final Function1<java.sql.ResultSet,​Function0<java.lang.Object>> AUTO_ROW_BUILDER_FACTORY
    • Constructor Detail

      • ResultSetEnumerable

        private ResultSetEnumerable​(javax.sql.DataSource dataSource,
                                    java.lang.String sql,
                                    Function1<java.sql.ResultSet,​Function0<T>> rowBuilderFactory)
    • Method Detail

      • of

        public static ResultSetEnumerable<java.lang.Object> of​(javax.sql.DataSource dataSource,
                                                               java.lang.String sql)
        Creates an ResultSetEnumerable.
      • of

        public static ResultSetEnumerable<java.lang.Object> of​(javax.sql.DataSource dataSource,
                                                               java.lang.String sql,
                                                               Primitive[] primitives)
        Creates an ResultSetEnumerable that retrieves columns as specific Java types.
      • of

        public static <T> ResultSetEnumerable<T> of​(javax.sql.DataSource dataSource,
                                                    java.lang.String sql,
                                                    Function1<java.sql.ResultSet,​Function0<T>> rowBuilderFactory)
        Executes a SQL query and returns the results as an enumerator, using a row builder to convert JDBC column values into rows.
      • of

        public static <T> ResultSetEnumerable<T> of​(javax.sql.DataSource dataSource,
                                                    java.lang.String sql,
                                                    Function1<java.sql.ResultSet,​Function0<T>> rowBuilderFactory,
                                                    ResultSetEnumerable.PreparedStatementEnricher consumer)
        Executes a SQL query and returns the results as an enumerator, using a row builder to convert JDBC column values into rows.

        It uses a PreparedStatement for computing the query result, and that means that it can bind parameters.

      • setTimeout

        public void setTimeout​(DataContext context)
      • setDynamicParam

        private static void setDynamicParam​(java.sql.PreparedStatement preparedStatement,
                                            int i,
                                            java.lang.Object value)
                                     throws java.sql.SQLException
        Assigns a value to a dynamic parameter in a prepared statement, calling the appropriate setXxx method based on the type of the value.
        Throws:
        java.sql.SQLException
      • enumerator

        public Enumerator<T> enumerator()
        Description copied from interface: RawEnumerable
        Returns an enumerator that iterates through a collection.
      • enumeratorBasedOnStatement

        private Enumerator<T> enumeratorBasedOnStatement()
      • enumeratorBasedOnPreparedStatement

        private Enumerator<T> enumeratorBasedOnPreparedStatement()
      • setTimeoutIfPossible

        private void setTimeoutIfPossible​(java.sql.Statement statement)
                                   throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • closeIfPossible

        private void closeIfPossible​(java.sql.Connection connection,
                                     java.sql.Statement statement)
      • primitiveRowBuilderFactory

        private static Function1<java.sql.ResultSet,​Function0<java.lang.Object>> primitiveRowBuilderFactory​(Primitive[] primitives)