public class TransactionPair extends java.lang.Object implements Transaction
Constructor and Description |
---|
TransactionPair(Transaction primaryTransaction,
Transaction secondaryTransaction) |
Modifier and Type | Method and Description |
---|---|
void |
attach()
Attaches this transaction to the current thread, if it has been
detached.
|
void |
commit()
If currently in a transaction, commits all changes to the storage layer
since the last commit within the transaction.
|
void |
detach()
Detaches this transaction from the current thread.
|
void |
exit()
Closes the current transaction, aborting all changes since the last
commit.
|
IsolationLevel |
getIsolationLevel()
Returns the isolation level of this transaction.
|
boolean |
isForUpdate()
Returns true if this transaction is in update mode, which is adjusted by
calling
Transaction.setForUpdate(boolean) . |
boolean |
preCommit()
Calling this method commits all nested child transactions, closes all
scoped cursors, and locks out some interactions from other threads.
|
void |
setDesiredLockTimeout(int timeout,
java.util.concurrent.TimeUnit unit)
Specify a desired timeout for aquiring locks within this
transaction.
|
void |
setForUpdate(boolean forUpdate)
Set to true to force all read operations within this transaction to
acquire upgradable or write locks.
|
public TransactionPair(Transaction primaryTransaction, Transaction secondaryTransaction)
primaryTransaction
- is committed first, exited lastsecondaryTransaction
- is exited first, commited lastpublic void commit() throws PersistException
Transaction
commit
in interface Transaction
PersistException
- if storage layer throws an exceptionpublic void exit() throws PersistException
Transaction
exit
in interface Transaction
PersistException
- if storage layer throws an exceptionpublic void setForUpdate(boolean forUpdate)
Transaction
setForUpdate
in interface Transaction
public boolean isForUpdate()
Transaction
Transaction.setForUpdate(boolean)
.isForUpdate
in interface Transaction
public void setDesiredLockTimeout(int timeout, java.util.concurrent.TimeUnit unit)
Transaction
Also, the range of lock timeout values supported might be small. For example, only a timeout value of zero might be supported. In that case, the transaction is configured to not wait at all when trying to acquire locks. Expect immediate timeout exceptions when locks cannot be granted.
Nested transactions inherit the desired lock timeout of their parent. Top transactions always begin with the default lock timeout.
setDesiredLockTimeout
in interface Transaction
timeout
- Desired lock timeout. If negative, revert lock timeout to
default value.unit
- Time unit for timeout. If null, revert lock timeout to
default value.public IsolationLevel getIsolationLevel()
Transaction
getIsolationLevel
in interface Transaction
public void detach()
Transaction
Detaching a transaction also detaches any parent and nested child transactions. Attaching any of them achieves the same result as attaching this transaction.
detach
in interface Transaction
public void attach()
Transaction
attach
in interface Transaction
public boolean preCommit() throws PersistException
Transaction
The intent of this method is to complete as many operations as possible leading up to the actual commit. If pre-commit succeeds, then commit will most likely succeed as well. While in a pre-commit state, the transaction can still be used by the current thread. Calling pre-commit again ensures that child transactions and cursors are closed.
preCommit
in interface Transaction
PersistException
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.