Package org.eclipse.edc.sql
Interface QueryExecutor
- All Known Implementing Classes:
SqlQueryExecutor
public interface QueryExecutor
Provides query capabilities to stores
-
Method Summary
Modifier and TypeMethodDescriptionintexecute(Connection connection, String sql, Object... arguments) Intended for mutating queries.<T> Stream<T>query(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments) Intended for reading queries.<T> Tsingle(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments) Intended for reading queries.
-
Method Details
-
execute
Intended for mutating queries.- Parameters:
sql- the parametrized sql queryarguments- 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 resultingStreammust 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 queryarguments- 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 queryarguments- the parameteres to interpolate with the parametrized sql query- Returns:
- the first entity that satisfies the query, null if none exists
-