public class SnapshotJTransaction extends JTransaction
JTransaction that persists indefinitely.
SnapshotJTransactions hold a "snapshot" some portion of the state of a JTransaction for later use.
Each SnapshotJTransaction contains its own set of "snapshot" JObjects that are (usually) copies of
the corresponding "real" database JObjects. Because a SnapshotJTransaction
lives indefinitely, these objects can be used just like normal Java objects, outside of any regular transaction.
In addition, JSimpleDB features such as indexing, listeners, validation, etc. also continue to work normally.
For convenience, each JTransaction has a default SnapshotJTransaction instance
associated with it; JObject.copyOut()
copies objects there.
More general usage is possible via JTransaction.createSnapshotTransaction().
For example, for KVDatabases that support it, using the key/value store snapshot returned by
KVTransaction.mutableSnapshot() allows an efficient copying of the entire database.
| Modifier and Type | Method and Description |
|---|---|
void |
commit()
Commit this transaction.
|
SnapshotTransaction |
getTransaction()
Get the
SnapshotTransaction associated with this instance. |
boolean |
isSnapshot()
Determine whether this instance is a
SnapshotJTransaction. |
boolean |
isValid()
Determine whether this transaction is still valid.
|
void |
reset()
Delete all objects contained in this snapshot transaction and reset it back to its initial state.
|
void |
rollback()
Roll back this transaction.
|
copyTo, copyTo, create, create, createSnapshotTransaction, delete, exists, get, get, get, getAll, getCurrent, getJSimpleDB, getKey, getKey, getSchemaVersion, getSnapshotTransaction, getValidationMode, invertReferencePath, performAction, queryCompositeIndex, queryCompositeIndex, queryCompositeIndex, queryIndex, queryIndex, queryListElementIndex, queryMapValueIndex, queryVersion, readCounterField, readListField, readMapField, readSetField, readSimpleField, recreate, registerJObject, resetValidationQueue, revalidate, setCurrent, updateSchemaVersion, validate, writeSimpleFieldpublic boolean isSnapshot()
JTransactionSnapshotJTransaction.isSnapshot in class JTransactionSnapshotJTransaction, otherwise falsepublic SnapshotTransaction getTransaction()
SnapshotTransaction associated with this instance.getTransaction in class JTransactionpublic void reset()
It will contain schema meta-data but no objects.
public void commit()
SnapshotJTransactions do not support this method and will always throw UnsupportedOperationException.
commit in class JTransactionUnsupportedOperationException - alwayspublic void rollback()
SnapshotJTransactions do not support this method and will always throw UnsupportedOperationException.
rollback in class JTransactionUnsupportedOperationException - alwayspublic boolean isValid()
SnapshotJTransactions are always valid.
isValid in class JTransactionTransaction.isValid()Copyright © 2017. All rights reserved.