Interface BaseDAO<S extends SQL>

All Known Implementing Classes:
FColorDao, FPlayerDAO, IgnoreDAO, MailDAO, ModerationDAO, SettingDAO, TimeDAO, VersionDAO

public interface BaseDAO<S extends SQL>
Base Data Access Object for database operations in FlectonePulse. Provides common methods for transaction and handle management.
Since:
0.9.0
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the database instance associated with this DAO.
    default S
    getSQL(org.jdbi.v3.core.Handle handle)
    Attaches the SQL interface to the given handle.
    default <R> R
    Executes a function within a transaction and returns the result.
    Class<? extends S>
    Gets the SQL interface class for this DAO.
    default void
    useCustomTransaction(Consumer<org.jdbi.v3.core.Handle> action)
    Executes an action within a transaction.
    default void
    useHandle(Consumer<S> action)
    Executes an action using a database handle.
    default void
    Executes an action within a transaction.
    default <R> R
    withHandle(Function<S,R> action)
    Executes a function using a database handle and returns the result.
  • Method Details

    • database

      Database database()
      Gets the database instance associated with this DAO.
      Returns:
      the database instance
    • sqlClass

      Class<? extends S> sqlClass()
      Gets the SQL interface class for this DAO.
      Returns:
      the SQL interface class
    • getSQL

      default S getSQL(org.jdbi.v3.core.Handle handle)
      Attaches the SQL interface to the given handle.
      Parameters:
      handle - the database handle
      Returns:
      the attached SQL interface
    • useTransaction

      default void useTransaction(Consumer<S> action)
      Executes an action within a transaction.
      Parameters:
      action - the action to execute
    • useCustomTransaction

      default void useCustomTransaction(Consumer<org.jdbi.v3.core.Handle> action)
      Executes an action within a transaction.
      Parameters:
      action - the action to execute with handle
    • inTransaction

      default <R> R inTransaction(Function<S,R> action)
      Executes a function within a transaction and returns the result.
      Type Parameters:
      R - the return type
      Parameters:
      action - the function to execute
      Returns:
      the result of the function
    • useHandle

      default void useHandle(Consumer<S> action)
      Executes an action using a database handle.
      Parameters:
      action - the action to execute
    • withHandle

      default <R> R withHandle(Function<S,R> action)
      Executes a function using a database handle and returns the result.
      Type Parameters:
      R - the return type
      Parameters:
      action - the function to execute
      Returns:
      the result of the function