public class SnapshotTransaction extends Transaction implements Closeable
Transaction
that persists indefinitely.
SnapshotTransaction
s hold a "snapshot" of some portion of the state of a Transaction
for later use. Each SnapshotTransaction
contains its own set of "snapshot" objects.
SnapshotTransaction
s can never be closed (i.e., committed or rolled-back); they persist in memory until
no longer referenced. Transaction.Callback
s may be registered but they will never be invoked.
SnapshotTransaction
s can be based on an arbitrary KVStore
;
see Database.createSnapshotTransaction()
.
Transaction.Callback, Transaction.CallbackAdapter, Transaction.ListenerSet
log
Modifier and Type | Method and Description |
---|---|
void |
addCallback(Transaction.Callback callback)
Register a transaction callback to be invoked when this transaction completes.
|
void |
close()
Close this instance and release any resources associated with it.
|
void |
commit()
Commit this transaction.
|
KVStore |
getKVStore()
Get the underlying
KVStore that holds this snapshot transaction's state. |
boolean |
isSnapshot()
Determine whether this instance is a
SnapshotTransaction . |
boolean |
isValid()
Determine whether this transaction is still valid.
|
void |
reset()
Delete all objects contained in this snapshot transaction.
|
void |
rollback()
Roll back this transaction.
|
addCreateListener, addDeleteListener, addFieldChangeListener, addListFieldChangeListener, addMapFieldChangeListener, addSetFieldChangeListener, addSimpleFieldChangeListener, addVersionChangeListener, adjustCounterField, copy, create, create, create, create, createSnapshotTransaction, delete, deleteSchemaVersion, exists, followReferencePath, generateId, getAll, getAll, getDatabase, getKey, getKey, getKVTransaction, getSchema, getSchemas, getSchemaVersion, getTypeDescription, getUserObject, invertReferencePath, isReadOnly, isRollbackOnly, queryCompositeIndex, queryCompositeIndex2, queryCompositeIndex3, queryCompositeIndex4, queryIndex, queryListElementIndex, queryMapValueIndex, queryVersion, readCounterField, readListField, readMapField, readSetField, readSimpleField, removeCreateListener, removeDeleteListener, removeFieldChangeListener, removeListFieldChangeListener, removeMapFieldChangeListener, removeSetFieldChangeListener, removeSimpleFieldChangeListener, removeVersionChangeListener, setListeners, setReadOnly, setRollbackOnly, setTimeout, setUserObject, snapshotListeners, updateSchemaVersion, writeCounterField, writeSimpleField
public boolean isSnapshot()
Transaction
SnapshotTransaction
.isSnapshot
in class Transaction
SnapshotTransaction
, otherwise falsepublic KVStore getKVStore()
KVStore
that holds this snapshot transaction's state.KVStore
public void reset()
Upon return, the underlying key/value store will still contain meta-data, but no objects.
public void commit()
SnapshotTransaction
s do not support this method and will always throw UnsupportedOperationException
.
commit
in class Transaction
UnsupportedOperationException
- alwayspublic void rollback()
SnapshotTransaction
s do not support this method and will always throw UnsupportedOperationException
.
rollback
in class Transaction
UnsupportedOperationException
- alwayspublic void addCallback(Transaction.Callback callback)
Transaction.Callback
s registered with a SnapshotTransaction
will by definition never be invoked.
Therefore, this method simply discards callback
.
addCallback
in class Transaction
callback
- callback to invokepublic boolean isValid()
SnapshotTransaction
s are always valid.
isValid
in class Transaction
public void close()
The implementation in SnapshotTransaction
closes the underlying KVStore
if it is
a CloseableKVStore
, otherwise it does nothing.
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2022. All rights reserved.