Package org.dizitart.no2.transaction
Class Session
java.lang.Object
org.dizitart.no2.transaction.Session
- All Implemented Interfaces:
AutoCloseable
A session represents a transactional context for a Nitrite database.
It provides methods to create a new transaction.
A session should be closed after use to release any resources associated with it.
If a session is closed and the transaction is not committed, all opened transactions will get rolled back and all volatile data gets discarded for the session.
- Since:
- 4.0
- Author:
- Anindya Chatterjee
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBegins a new transaction.voidChecks state of the session.voidclose()
-
Constructor Details
-
Session
Instantiates a new Session.- Parameters:
nitrite- the nitritelockService- the lock service
-
-
Method Details
-
beginTransaction
Begins a new transaction.- Returns:
- the new transaction.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
checkState
public void checkState()Checks state of the session. If the session is not active, it will throw aTransactionException.- Throws:
TransactionException- when the session is not active, and a transaction is initiated in this session.
-