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 Details

    • setSlowQueriesThreshold

      void setSlowQueriesThreshold(Duration threshold)
      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

      void executeSql(String sqlScript)
      Execute a given SQL code inside this transaction.
      Parameters:
      sqlScript - the sql script to execute
    • doSqlWork

      void doSqlWork(TopiaSqlWork sqlWork)
      Runs the given SQL work on the current context
      Parameters:
      sqlWork - the SQL work instance to execute
    • findSingleResult

      <O> O findSingleResult(TopiaSqlQuery<O> query) throws TopiaException
      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 null if none found.
      Throws:
      TopiaException - for any pb
    • findSingleResult

      <O> O findSingleResult(SqlFunction<Connection,PreparedStatement> preparer, SqlFunction<ResultSet,O> transformer) throws TopiaException
      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 query
      transformer - function to transform the ResultSet into the expected element
      Returns:
      the single result or null if none found.
      Throws:
      TopiaException - for any pb
    • findSingleResult

      <O> O findSingleResult(String sql, SqlFunction<ResultSet,O> transformer) throws TopiaException
      Runs the given SQL query and return its first result if there is some.
      Type Parameters:
      O - type of result
      Parameters:
      sql - the sql query
      transformer - function to transform the ResultSet into the expected element
      Returns:
      the single result or null if none found.
      Throws:
      TopiaException - for any pb
    • findMultipleResult

      <O> List<O> findMultipleResult(TopiaSqlQuery<O> query) throws TopiaException
      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,O> transformer) throws TopiaException
      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 query
      transformer - 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 TopiaException
      Runs the given SQL query and return all his result if there is some.
      Type Parameters:
      O - type of result
      Parameters:
      sql - the sql query
      transformer - 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