Class SqlQueryExecutor

java.lang.Object
org.eclipse.edc.sql.SqlQueryExecutor
All Implemented Interfaces:
QueryExecutor

public class SqlQueryExecutor extends Object implements QueryExecutor
The SqlQueryExecutor is capable of executing parametrized SQL queries
  • Constructor Details

  • Method Details

    • execute

      public int execute(Connection connection, String sql, Object... arguments)
      Description copied from interface: QueryExecutor
      Intended for mutating queries.
      Specified by:
      execute in interface QueryExecutor
      sql - the parametrized sql query
      arguments - the parameters to interpolate with the parametrized sql query
      Returns:
      rowsChanged
    • single

      public <T> T single(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments)
      Description copied from interface: QueryExecutor
      Intended for reading queries. Return the first entity that satisfies the query, null if none exists
      Specified by:
      single in interface QueryExecutor
      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
    • query

      public <T> Stream<T> query(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments)
      Description copied from interface: QueryExecutor
      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...)
      Specified by:
      query in interface QueryExecutor
      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...)