Interface TopiaSqlSupport
- All Known Implementing Classes:
HibernateTopiaSqlSupport
public interface TopiaSqlSupport
This API provides methods to run SQL queries
- Since:
- 3.0
- Author:
- Arnaud Thimel (Code Lutin)
-
Method Summary
Modifier and TypeMethodDescriptionvoiddoSqlWork(TopiaSqlWork sqlWork) Runs the given SQL work on the current contextvoidexecuteSql(String sqlScript) Execute a given SQL code inside this transaction.<O> List<O>findMultipleResult(String sql, SqlFunction<ResultSet, O> transformer) Runs the given SQL query and return all his result if there is some.<O> List<O>findMultipleResult(SqlFunction<Connection, PreparedStatement> preparer, SqlFunction<ResultSet, O> transformer) Runs the given SQL query and return all his result if there is some.<O> List<O>findMultipleResult(TopiaSqlQuery<O> query) Runs the given SQL query and return all his result if there is some.<O> OfindSingleResult(String sql, SqlFunction<ResultSet, O> transformer) Runs the given SQL query and return its first result if there is some.<O> OfindSingleResult(SqlFunction<Connection, PreparedStatement> preparer, SqlFunction<ResultSet, O> transformer) Runs the given SQL query and return its first result if there is some.<O> OfindSingleResult(TopiaSqlQuery<O> query) Runs the given SQL query and return its first result if there is some.voidsetSlowQueriesThreshold(Duration threshold) Tells to the context after which delay a query should be considered as slow.
-
Method Details
-
setSlowQueriesThreshold
Tells to the context after which delay a query should be considered as slow. Default value is to skip slow queries watching unless specified in application configuration.- Parameters:
threshold- the new value to set- Since:
- 3.8
-
executeSql
Execute a given SQL code inside this transaction.- Parameters:
sqlScript- the sql script to execute
-
doSqlWork
Runs the given SQL work on the current context- Parameters:
sqlWork- the SQL work instance to execute
-
findSingleResult
Runs the given SQL query and return its first result if there is some.- Type Parameters:
O- type of result- Parameters:
query- query to play- Returns:
- the single result or
nullif none found. - Throws:
TopiaException- for any pb
-
findSingleResult
<O> O findSingleResult(SqlFunction<Connection, PreparedStatement> preparer, SqlFunction<ResultSet, throws TopiaExceptionO> transformer) Runs the given SQL query and return its first result if there is some.- Type Parameters:
O- type of result- Parameters:
preparer- function to prepare the querytransformer- function to transform the ResultSet into the expected element- Returns:
- the single result or
nullif none found. - Throws:
TopiaException- for any pb
-
findSingleResult
Runs the given SQL query and return its first result if there is some.- Type Parameters:
O- type of result- Parameters:
sql- the sql querytransformer- function to transform the ResultSet into the expected element- Returns:
- the single result or
nullif none found. - Throws:
TopiaException- for any pb
-
findMultipleResult
Runs the given SQL query and return all his result if there is some.- Type Parameters:
O- type of result- Parameters:
query- query to play- Returns:
- the list of results (the list is empty if query returns no result).
- Throws:
TopiaException- for any pb
-
findMultipleResult
<O> List<O> findMultipleResult(SqlFunction<Connection, PreparedStatement> preparer, SqlFunction<ResultSet, throws TopiaExceptionO> transformer) Runs the given SQL query and return all his result if there is some.- Type Parameters:
O- type of result- Parameters:
preparer- function to prepare the querytransformer- function to transform the ResultSet into the expected element- Returns:
- the list of results (the list is empty if query returns no result).
- Throws:
TopiaException- for any pb
-
findMultipleResult
<O> List<O> findMultipleResult(String sql, SqlFunction<ResultSet, O> transformer) throws TopiaExceptionRuns the given SQL query and return all his result if there is some.- Type Parameters:
O- type of result- Parameters:
sql- the sql querytransformer- function to transform the ResultSet into the expected element- Returns:
- the list of results (the list is empty if query returns no result).
- Throws:
TopiaException- for any pb
-