Interface IMysqlHelper

All Known Implementing Classes:
MySqlHelper

public interface IMysqlHelper
  • Method Details

    • execute

      boolean execute(String metric, String sql, IMysqlHelper.IStatementBuilder statementBuilder)
      Execute a SQL (Do not use it for UPDATE query - use executeUpdate)

      NOTE - a "CREATE TABLE" using this returns false (as per the Java Doc of PreparedStatement)

      Parameters:
      metric - metric name to log this execution
      sql - SQL to execute
      statementBuilder - callback hook to set param in SQL statement
      Returns:
      true if success otherwise false
    • executeUpdate

      boolean executeUpdate(String metric, String sql, IMysqlHelper.IStatementBuilder statementBuilder)
      Execute a SQL
      Parameters:
      metric - metric name to log this execution
      sql - SQL to execute
      statementBuilder - callback hook to set param in SQL statement
      Returns:
      true if success otherwise false
    • persist

      Long persist(String metric, String sql, IMysqlHelper.IStatementBuilder statementBuilder)
      Persist a record
      Parameters:
      metric - metric name to log this execution
      sql - SQL to execute
      statementBuilder - callback hook to set param in SQL statement
      Returns:
      PK for this row as long
    • persist

      <T> T persist(String metric, String sql, IMysqlHelper.IStatementBuilder statementBuilder, Function<ResultSet,T> keyFunction)
      Persist a record
      Parameters:
      metric - metric name to log this execution
      sql - SQL to execute
      statementBuilder - callback hook to set param in SQL statement
      keyFunction - function to extract key of this row
      Returns:
      PK for this row
    • findOne

      <T> Optional<T> findOne(String metric, String sql, IMysqlHelper.IStatementBuilder statementBuilder, IMysqlHelper.IRowMapper<T> rowMapper, Class<T> cls)
      Fina a single record
      Parameters:
      metric - metric name to log this execution
      sql - SQL to execute
      statementBuilder - callback hook to set param in SQL statement
      rowMapper - mapper to build object from DB row
      Returns:
      Optional object with found record
    • findAll

      <T> Optional<List<T>> findAll(String metric, String sql, IMysqlHelper.IStatementBuilder statementBuilder, IMysqlHelper.IRowMapper<T> rowMapper, Class<T> cls)
      Fina all record
      Parameters:
      metric - metric name to log this execution
      sql - SQL to execute
      statementBuilder - callback hook to set param in SQL statement
      rowMapper - mapper to build object from DB row
      Returns:
      Optional object (of type list) with found record