Interface ResultPacker<T>

  • Type Parameters:
    T - the type of object resulting from the packing

    public interface ResultPacker<T>
    A ResultPacker packs the contents of a ResultSet into a List.
    • Method Detail

      • pack

        default List<T> pack​(ResultSet resultSet)
                      throws SQLException
        Iterates through the given ResultSet, packing its contents into a List using fetch(ResultSet) in the order they appear. Items are skipped if fetch(ResultSet) returns null. This method does not close or modify the ResultSet in any way.
        Parameters:
        resultSet - the ResultSet instance containing the query result to process
        Returns:
        a List containing the data from the query result
        Throws:
        SQLException - thrown if anything goes wrong during the packing
        NullPointerException - in case resultSet is null
      • pack

        default List<T> pack​(ResultSet resultSet,
                             int fetchLimit)
                      throws SQLException
        Iterates through the given ResultSet, packing its contents into a List using fetch(ResultSet) in the order they appear. Items are skipped if fetch(ResultSet) returns null. This method does not close or modify the ResultSet in any way.
        Parameters:
        resultSet - the ResultSet instance containing the query result to process
        fetchLimit - the maximum number of records to fetch from the result set, a negative value means all should be fetched.
        Returns:
        a List containing the data from the query result
        Throws:
        SQLException - thrown if anything goes wrong during the packing
        NullPointerException - in case resultSet is null
      • fetch

        T fetch​(ResultSet resultSet)
         throws SQLException
        Fetches a single instance from the given result set, assumes ResultSet.next() has been called
        Parameters:
        resultSet - the result set
        Returns:
        the instance fetched from the ResultSet, null if the item should not be fetched for some reason
        Throws:
        SQLException - in case of failure