Interface QueryExecutor

All Known Implementing Classes:
SqlQueryExecutor

public interface QueryExecutor
Provides query capabilities to stores
  • Method Details

    • execute

      int execute(Connection connection, String sql, Object... arguments)
      Intended for mutating queries.
      Parameters:
      sql - the parametrized sql query
      arguments - the parameters to interpolate with the parametrized sql query
      Returns:
      rowsChanged
    • query

      <T> Stream<T> query(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments)
      Intended for reading queries. The resulting Stream must be closed with the "close()" when a terminal operation is used on the stream (collect, forEach, anyMatch, etc...)
      Type Parameters:
      T - generic type returned after mapping from the executed query
      Parameters:
      connection - the connection to be used to execute the query.
      closeConnection - if true the connection will be closed on stream closure, else it won't be closed.
      resultSetMapper - able to map a row to an object e.g. pojo.
      sql - the parametrized sql query
      arguments - the parameteres to interpolate with the parametrized sql query
      Returns:
      a Stream on the results, must be closed when a terminal operation is used on the stream (collect, forEach, anyMatch, etc...)
    • single

      <T> T single(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments)
      Intended for reading queries. Return the first entity that satisfies the query, null if none exists
      Type Parameters:
      T - generic type returned after mapping from the executed query
      Parameters:
      connection - the connection to be used to execute the query.
      closeConnection - if true the connection will be closed on stream closure, else it won't be closed.
      resultSetMapper - able to map a row to an object e.g. pojo.
      sql - the parametrized sql query
      arguments - the parameteres to interpolate with the parametrized sql query
      Returns:
      the first entity that satisfies the query, null if none exists