Interface OTransaction
- All Known Subinterfaces:
OTransactionInternal
- All Known Implementing Classes:
OTransactionAbstract,OTransactionNoTx,OTransactionOptimistic,OTransactionOptimisticClient,OTransactionOptimisticDistributed,OTransactionOptimisticProxy,OTransactionOptimisticServer,OTransactionRealAbstract
public interface OTransaction
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumstatic enumstatic enum -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangedDocument(ODocument document) Adds the given document to a set of changed documents known to this transaction.voidaddIndexEntry(OIndex index, String indexName, OTransactionIndexChanges.OPERATION operation, Object key, OIdentifiable value) Adds the transactional index entry in this transaction.intvoidbegin()voidDeprecated.voidDeprecated.voidclose()voidcommit()voidcommit(boolean force) voiddeleteRecord(ORecord record, ODatabase.OPERATION_MODE mode) Deletes the given record in this transaction.default intIterable<? extends ORecordOperation>Deprecated.getCustomData(String name) Obtains the custom value by its name stored in the context of this transaction.intintgetId()getIndexChanges(String indexName) Obtains the index changes done in the context of this transaction.getIndexChangesInternal(String indexName) Does the same thing asgetIndexChanges(String), but handles remote storages in a special way.Returns the current isolation level.getNewRecordEntriesByClass(OClass iClass, boolean iPolymorphic) getNewRecordEntriesByClusterIds(int[] iIds) Resolves a record with the given RID in the context of this transaction.getRecordEntry(ORID rid) Iterable<? extends ORecordOperation>booleanisActive()booleanisLockedRecord(OIdentifiable iRecord) booleanloadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache) loadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache, boolean iUpdateCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated.loadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated.loadRecordIfVersionIsNotLatest(ORID rid, int recordVersion, String fetchPlan, boolean ignoreCache) lockingStrategy(OIdentifiable iRecord) Deprecated.lockRecord(OIdentifiable iRecord, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated.reloadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache) reloadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache, boolean force) voidrollback()voidrollback(boolean force, int commitLevelDiff) saveRecord(ORecord record, String clusterName, ODatabase.OPERATION_MODE operationMode, boolean forceCreate, ORecordCallback<? extends Number> createdCallback, ORecordCallback<Integer> updatedCallback) Saves the given record in this transaction.voidsetCustomData(String name, Object value) Sets the custom value by its name stored in the context of this transaction.setIsolationLevel(OTransaction.ISOLATION_LEVEL iIsolationLevel) Changes the isolation level.voidsetUsingLog(boolean useLog) Deprecated.This option has no effectunlockRecord(OIdentifiable iRecord) Deprecated.voidupdateIdentityAfterCommit(ORID oldRid, ORID newRid) When commit in transaction is performed all new records will change their identity, but index values will contain stale links, to fix them given method will be called for each entry.
-
Method Details
-
begin
void begin() -
commit
void commit() -
commit
void commit(boolean force) -
rollback
void rollback() -
getIsolationLevel
OTransaction.ISOLATION_LEVEL getIsolationLevel()Returns the current isolation level. -
setIsolationLevel
Changes the isolation level. Default is READ_COMMITTED. When REPEATABLE_READ is set, any record read from the storage is cached in memory to guarantee the repeatable reads. This affects the used RAM and speed (because JVM Garbage Collector job).- Parameters:
iIsolationLevel- Isolation level to set- Returns:
- Current object to allow call in chain
-
rollback
void rollback(boolean force, int commitLevelDiff) -
getDatabase
ODatabaseDocument getDatabase() -
clearRecordEntries
Deprecated. -
loadRecord
@Deprecated ORecord loadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated. -
loadRecord
@Deprecated ORecord loadRecord(ORID iRid, ORecord iRecord, String iFetchPlan, boolean ignoreCache, boolean iUpdateCache, boolean loadTombstone, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated. -
loadRecord
-
reloadRecord
-
reloadRecord
-
loadRecordIfVersionIsNotLatest
ORecord loadRecordIfVersionIsNotLatest(ORID rid, int recordVersion, String fetchPlan, boolean ignoreCache) throws ORecordNotFoundException - Throws:
ORecordNotFoundException
-
getStatus
OTransaction.TXSTATUS getStatus() -
getCurrentRecordEntries
Deprecated. -
getRecordOperations
Iterable<? extends ORecordOperation> getRecordOperations() -
getNewRecordEntriesByClass
-
getNewRecordEntriesByClusterIds
-
getRecordEntry
-
getInvolvedIndexes
-
getIndexChanges
ODocument getIndexChanges() -
clearIndexEntries
Deprecated. -
isUsingLog
boolean isUsingLog() -
setUsingLog
Deprecated.This option has no effectIf you set this flag to false, you are unable to- Rollback data changes in case of exception
- Restore data in case of server crash
So you practically unable to work in multithreaded environment and keep data consistent.
-
close
void close() -
updateIdentityAfterCommit
When commit in transaction is performed all new records will change their identity, but index values will contain stale links, to fix them given method will be called for each entry. This update local transaction maps too.- Parameters:
oldRid- Record identity before commit.newRid- Record identity after commit.
-
amountOfNestedTxs
int amountOfNestedTxs() -
isLockedRecord
-
lockingStrategy
Deprecated. -
lockRecord
@Deprecated OTransaction lockRecord(OIdentifiable iRecord, OStorage.LOCKING_STRATEGY iLockingStrategy) Deprecated. -
unlockRecord
Deprecated. -
getEntryCount
int getEntryCount() -
isActive
boolean isActive()- Returns:
trueif this transaction is active,falseotherwise.
-
saveRecord
ORecord saveRecord(ORecord record, String clusterName, ODatabase.OPERATION_MODE operationMode, boolean forceCreate, ORecordCallback<? extends Number> createdCallback, ORecordCallback<Integer> updatedCallback) Saves the given record in this transaction.- Parameters:
record- the record to save.clusterName- record's cluster name.operationMode- the operation mode.forceCreate- the force creation flag,trueto force the creation of the record,falseto allow updates.createdCallback- the callback to invoke when the record save operation triggered the creation of the record.updatedCallback- the callback to invoke when the record save operation triggered the update of the record.- Returns:
- the record saved.
-
deleteRecord
Deletes the given record in this transaction.- Parameters:
record- the record to delete.mode- the operation mode.
-
getRecord
Resolves a record with the given RID in the context of this transaction.- Parameters:
rid- the record RID.- Returns:
- the resolved record, or
nullif no record is found, orOTransactionAbstract.DELETED_RECORDif the record was deleted in this transaction.
-
addIndexEntry
void addIndexEntry(OIndex index, String indexName, OTransactionIndexChanges.OPERATION operation, Object key, OIdentifiable value) Adds the transactional index entry in this transaction.- Parameters:
index- the index.indexName- the index name.operation- the index operation to register.key- the index key.value- the index key value.
-
addChangedDocument
Adds the given document to a set of changed documents known to this transaction.- Parameters:
document- the document to add.
-
getIndexChanges
Obtains the index changes done in the context of this transaction.- Parameters:
indexName- the index name.- Returns:
- the index changes in question or
nullif index is not found.
-
getIndexChangesInternal
Does the same thing asgetIndexChanges(String), but handles remote storages in a special way.- Parameters:
indexName- the index name.- Returns:
- the index changes in question or
nullif index is not found or storage is remote.
-
getCustomData
Obtains the custom value by its name stored in the context of this transaction.- Parameters:
name- the value name.- Returns:
- the obtained value or
nullif no value found.
-
setCustomData
Sets the custom value by its name stored in the context of this transaction.- Parameters:
name- the value name.value- the value to store.
-
getClientTransactionId
default int getClientTransactionId()- Returns:
- this transaction ID as seen by the client of this transaction.
-
getId
int getId()
-