Interface DatabaseAPI.Query

All Superinterfaces:
AutoCloseable, DatabaseAPI.StatementCommon
Enclosing interface:
DatabaseAPI

public static interface DatabaseAPI.Query
extends DatabaseAPI.StatementCommon
Wrapping a prepared query to be more suitable for Java 8 onwards. This supports prepared statements that yield result sets.
Author:
Donal Fellows
  • Method Details

    • call

      <T> List<T> call​(DatabaseAPI.RowMapper<T> mapper, Object... arguments)
      Run the query on the given arguments to read a list of objects.
      Type Parameters:
      T - The type of the result.
      Parameters:
      mapper - Mapper that gets an object from a row set.
      arguments - Positional argument to the query
      Returns:
      The resulting list of objects.
    • call1

      <T> Optional<T> call1​(DatabaseAPI.RowMapper<T> mapper, Object... arguments)
      Run the query on the given arguments to read a single object.
      Type Parameters:
      T - The type of the result.
      Parameters:
      mapper - Mapper that gets an object from a row set.
      arguments - Positional argument to the query.
      Returns:
      The resulting object.
    • getColumns

      List<String> getColumns() throws DataAccessException
      Get the column names from the result set that this query will generate. This may be an expensive operation; it's use is not recommended outside of test code.
      Returns:
      The list of column names. The names of columns where they are not assigned by the query is arbitrary and up to the database engine. This will be null if the manipulation of metadata fails; this isn't expected.
      Throws:
      DataAccessException - If the statement is invalid SQL. Or if the DB connector has a bug (like the MySQL one does), alas.