All Downloads are FREE. Search and download functionalities are using the official Maven repository.

woko.persistence.TransactionalStore Maven / Gradle / Ivy

The newest version!
package woko.persistence;

/**
 * Interface for transactional ObjectStore implementations.
 * Uses a callback mechanism to execute the code inside a databse transaction.
 */
public interface TransactionalStore {

    /**
     * Executes callback inside a transaction and return the result
     * @param callback the callback to be executed
     * @param  the type of the result returned by the callback
     * @return the result of callback execution
     */
     RES doInTransactionWithResult(TransactionCallbackWithResult callback);

    /**
     * Execute passed callback inside a transaction.
     * @param callback the callback to be executed
     */
    void doInTransaction(TransactionCallback callback);

    /**
     * Return the current transaction if any.
     * @return the current transaction if any, null is no tx is open
     */
    StoreTransaction getCurrentTransaction();

    /**
     * Create and return a new, active transaction. This should fire begin transaction in
     * the underlying database system.
     * If a transaction is already running, then it should simply return this one
     * and do no additional work.
     * @return a new transaction if there was no tx open, the current tx otherwise
     */
    StoreTransaction beginTransaction();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy