Package org.dizitart.no2.transaction
Class Session
- java.lang.Object
-
- org.dizitart.no2.transaction.Session
-
- All Implemented Interfaces:
AutoCloseable
public class Session extends Object implements 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Transaction
beginTransaction()
Begins a new transaction.void
checkState()
Checks state of the session.void
close()
-
-
-
Constructor Detail
-
Session
public Session(Nitrite nitrite, org.dizitart.no2.common.concurrent.LockService lockService)
Instantiates a new Session.- Parameters:
nitrite
- the nitritelockService
- the lock service
-
-
Method Detail
-
beginTransaction
public Transaction beginTransaction()
Begins a new transaction.- Returns:
- the new transaction.
-
close
public void close()
- Specified by:
close
in 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.
-
-