Interface ControlDAO

All Known Implementing Classes:
AbstractControlDAOImpl, ControlDAOImpl, ControlDAOImpl.PostgreSQL

public interface ControlDAO
DAO services for database control statements. It is sometimes necessary to issue control statements on a database connection; these are not usually supported in the ANSI SQL standard.
Since:
3.2SP1
Author:
Derek Hulley
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a "Save Point" in the current transaction, for later selective rollback.
    void
    Execute statements that were queued for batching.
    void
    Remove a previously-created "Save Point", writing any intervening updates into the current transaction.
    void
    Roll back to a previously-created "Save Point", discarding any intervening changes to the current transaction.
    int
    setTransactionIsolationLevel(int isolationLevel)
    Change the current transaction isolation level.
    void
    Begin batching prepared statements for later execution.
  • Method Details

    • startBatch

      void startBatch()
      Begin batching prepared statements for later execution.
      See Also:
    • executeBatch

      void executeBatch()
      Execute statements that were queued for batching.
      See Also:
    • createSavepoint

      Savepoint createSavepoint(String savepoint)
      Create a "Save Point" in the current transaction, for later selective rollback. Creation must be accompanied by a matching rollbackToSavepoint(Savepoint) or releaseSavepoint(Savepoint).
        Savepoint savepoint = controlDAO.createSavepoint("functionF");
        try
        {
            // Do something that could fail e.g. blind insert that might violate unique constraints
            ...
            // Success, so remove savepoint or risk crashing on long-running transactions
            controlDAO.releaseSavepoint(savepoint);
        }
        catch (Throwable e)
        {
            controlDAO.rollbackToSavepoint(savepoint);
            // Throw something that client code might be able to react to or try something else
            ...
        }
       
      Parameters:
      savepoint - the name of the save point
      Returns:
      Returns the handle to the savepoint or null if the implementation does not support it
    • rollbackToSavepoint

      void rollbackToSavepoint(Savepoint savepoint)
      Roll back to a previously-created "Save Point", discarding any intervening changes to the current transaction.
      Parameters:
      savepoint - a previously-created savepoint
      See Also:
    • releaseSavepoint

      void releaseSavepoint(Savepoint savepoint)
      Remove a previously-created "Save Point", writing any intervening updates into the current transaction.
      Parameters:
      savepoint - the name of the save point
      See Also:
    • setTransactionIsolationLevel

      int setTransactionIsolationLevel(int isolationLevel)
      Change the current transaction isolation level.

      Note: The isolation level should not - and for some DBs, cannot - be changed except at the very start of the transaction

      Parameters:
      isolationLevel - the transaction isolation level
      Returns:
      Returns the previously-set isolation
      Throws:
      IllegalStateException - if the isolation level is invalid or cannot be changed