Package org.eclipse.edc.sql
Class SqlQueryExecutor
java.lang.Object
org.eclipse.edc.sql.SqlQueryExecutor
- All Implemented Interfaces:
QueryExecutor
The SqlQueryExecutor is capable of executing parametrized SQL queries
-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
SqlQueryExecutor
public SqlQueryExecutor() -
SqlQueryExecutor
-
-
Method Details
-
execute
Description copied from interface:QueryExecutorIntended for mutating queries.- Specified by:
executein interfaceQueryExecutorsql- the parametrized sql queryarguments- 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:QueryExecutorIntended for reading queries. Return the first entity that satisfies the query, null if none exists- Specified by:
singlein interfaceQueryExecutor- 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
-
query
public <T> Stream<T> query(Connection connection, boolean closeConnection, ResultSetMapper<T> resultSetMapper, String sql, Object... arguments) Description copied from interface:QueryExecutorIntended for reading queries. The resultingStreammust be closed with the "close()" when a terminal operation is used on the stream (collect, forEach, anyMatch, etc...)- Specified by:
queryin interfaceQueryExecutor- 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...)
-