Package org.dizitart.no2.transaction
Interface Transaction
- All Superinterfaces:
AutoCloseable
Represents a transaction in Nitrite database. It provides methods to perform
transactional operations on Nitrite database collections and repositories.
A transaction can be committed or rolled back. Once a transaction is committed, all changes made during the transaction are persisted to the underlying store. If a transaction is rolled back, all changes made during the transaction are discarded.
NOTE: Certain operations are auto-committed in Nitrite database. Those operations are not part of a transaction and cannot be rolled back. The following operations are auto-committed:
PersistentCollection.createIndex(String...)PersistentCollection.createIndex(IndexOptions, String...)PersistentCollection.rebuildIndex(String...)PersistentCollection.dropIndex(String...)PersistentCollection.dropAllIndices()PersistentCollection.clear()PersistentCollection.drop()PersistentCollection.close()PersistentCollection.createIndex(String...)PersistentCollection.createIndex(IndexOptions, String...)PersistentCollection.rebuildIndex(String...)PersistentCollection.dropIndex(String...)PersistentCollection.dropAllIndices()PersistentCollection.clear()PersistentCollection.drop()PersistentCollection.close()
- Since:
- 4.0
- Author:
- Anindya Chatterjee
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes thisTransaction.voidcommit()Completes the transaction and commits the data to the underlying store.getCollection(String name) Gets aNitriteCollectionto perform transactional operations on it.getId()Gets the unique identifier of the transaction.<T> ObjectRepository<T>getRepository(Class<T> type) Gets anObjectRepositoryto perform transactional operations on it.<T> ObjectRepository<T>getRepository(Class<T> type, String key) Gets anObjectRepositoryto perform transactional operations on it.<T> ObjectRepository<T>getRepository(EntityDecorator<T> entityDecorator) Gets anObjectRepositoryto perform transactional operations on it.<T> ObjectRepository<T>getRepository(EntityDecorator<T> entityDecorator, String key) Gets anObjectRepositoryto perform transactional operations on it.getState()Returns the current state of the transaction.voidrollback()Rolls back the transaction, discarding any changes made during the transaction.
-
Method Details
-
getId
String getId()Gets the unique identifier of the transaction.- Returns:
- the unique identifier of the transaction.
-
getState
TransactionState getState()Returns the current state of the transaction.- Returns:
- the current state of the transaction.
-
getCollection
Gets aNitriteCollectionto perform transactional operations on it.- Parameters:
name- the name- Returns:
- the collection
-
getRepository
Gets anObjectRepositoryto perform transactional operations on it.- Type Parameters:
T- the type parameter- Parameters:
type- the type- Returns:
- the repository
-
getRepository
Gets anObjectRepositoryto perform transactional operations on it.- Type Parameters:
T- the type parameter- Parameters:
type- the typekey- the key- Returns:
- the repository
-
getRepository
Gets anObjectRepositoryto perform transactional operations on it.- Type Parameters:
T- the type parameter- Parameters:
entityDecorator- the entityDecorator- Returns:
- the repository
-
getRepository
Gets anObjectRepositoryto perform transactional operations on it.- Type Parameters:
T- the type parameter- Parameters:
entityDecorator- the entityDecoratorkey- the key- Returns:
- the repository
-
commit
void commit()Completes the transaction and commits the data to the underlying store. -
rollback
void rollback()Rolls back the transaction, discarding any changes made during the transaction. -
close
void close()Closes thisTransaction.- Specified by:
closein interfaceAutoCloseable
-