public class CurrentTransaction
extends java.lang.Object
TransactionRunner
class. However, both methods of transaction control manage per-thread
transactions.Modifier and Type | Method and Description |
---|---|
STransaction |
abortTransaction()
Aborts the transaction that is active for the current thread for this
environment and makes the parent transaction (if any) the current
transaction.
|
STransaction |
beginTransaction(STransactionConfig config)
Begins a new transaction for this environment and associates it with
the current thread.
|
STransaction |
commitTransaction()
Commits the transaction that is active for the current thread for this
environment and makes the parent transaction (if any) the current
transaction.
|
SEnvironment |
getEnvironment()
Returns the underlying Berkeley DB environment.
|
static CurrentTransaction |
getInstance(SEnvironment env)
Gets the CurrentTransaction accessor for a specified Berkeley DB
environment.
|
STransaction |
getTransaction()
Returns the transaction associated with the current thread for this
environment, or null if no transaction is active.
|
public static CurrentTransaction getInstance(SEnvironment env)
env
- is an open Berkeley DB environment.public final SEnvironment getEnvironment()
public final STransaction getTransaction()
public final STransaction beginTransaction(STransactionConfig config) throws SDatabaseException
config
- the transaction configuration used for calling
SEnvironment.beginTransaction(com.sleepycat.client.STransaction, com.sleepycat.client.STransactionConfig)
, or null to use the default
configuration.SDatabaseException
- if the transaction cannot be started, in which
case any existing transaction is not affected.java.lang.IllegalStateException
- if a transaction is already active and
nested transactions are not supported by the environment.public final STransaction commitTransaction() throws SDatabaseException, java.lang.IllegalStateException
SDatabaseException
- if an error occurs committing the transaction.
The transaction will still be closed and the parent transaction will
become the current transaction.java.lang.IllegalStateException
- if no transaction is active for the
current thread for this environment.public final STransaction abortTransaction() throws SDatabaseException, java.lang.IllegalStateException
SDatabaseException
- if an error occurs aborting the transaction.
The transaction will still be closed and the parent transaction will
become the current transaction.java.lang.IllegalStateException
- if no transaction is active for the
current thread for this environment.Copyright (c) 2016, 2019 Oracle and/or its affiliates. All rights reserved.