com.scalar.db.sql.SqlTransaction Maven / Gradle / Ivy
package com.scalar.db.sql;
import com.scalar.db.sql.exception.SqlException;
import com.scalar.db.sql.exception.TransactionRetryableException;
import com.scalar.db.sql.exception.UnknownTransactionStatusException;
/** A transaction abstraction for ScalarDB SQL API. */
public interface SqlTransaction extends SqlStatementExecutable {
/**
* Returns the ID of a transaction.
*
* @return the ID of a transaction
*/
String getId();
/**
* Commits a transaction.
*
* @throws TransactionRetryableException if the transaction fails to commit due to retryable
* faults (e.g., a transaction conflict). You can retry the transaction from the beginning.
* @throws UnknownTransactionStatusException if the transaction status (committed or aborted) is
* unknown
* @throws SqlException if the transaction fails to commit due to transient or nontransient
* faults. You can try retrying the transaction from the beginning, but the transaction may
* still fail if the cause is nontranient
*/
void commit();
/** Rolls back a transaction. */
void rollback();
/** Aborts a transaction. This method is an alias of {@link #rollback()}. */
default void abort() {
rollback();
}
}