Class Session
- All Implemented Interfaces:
Closeable, AutoCloseable
A Session is a stateful period of activity of a user with the Database.
All the manipulation of a Database must be enclosed into a Session. A Session can be initiated from a Database instance and allows for getting a Graph instance which represents the persistent graph (the graph database).
Also, temporary data is associated to the Session, thus when a Session is closed, all the temporary data associated to the Session is removed too. Objects or Values instances or even session attributes are an example of temporary data.
Moreover, a Session is exclusive for a thread, thus if it is shared among threads results may be fatal or unexpected.
Check out the 'Processing' and 'Transactions' sections in the SPARKSEE User Manual for details about how Sessions work and the use of transactions.
- Author:
- Sparsity Technologies http://www.sparsity-technologies.com
-
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Begins a transaction.voidBegins an update transaction.voidclose()Closes the Session instance.voidcommit()Commits a transaction.getGraph()Gets the Graph instance.longGets the capacity of the in-memory pool.booleanisClosed()Gets if Session instance has been closed or not.Creates a new Objects instance.newQuery(QueryLanguage lang) Creates a new Query.longPreCommits a transaction.voidrollback()Rollbacks a transaction.
-
Method Details
-
rollback
public void rollback()Rollbacks a transaction. -
preCommit
public long preCommit()PreCommits a transaction.YOU SHOULD NOT USE THIS METHOD. This method exists for a specific service and it is used to force that the transaction is written in the recovery log even though it had not been committed yet (and may never be).
- Returns:
- The transaction id. This has to be used in RedoPrecommited in case of a recovery process.
-
begin
public void begin()Begins a transaction. -
beginUpdate
public void beginUpdate()Begins an update transaction. -
newQuery
Creates a new Query.- Parameters:
lang- The query language to create the query for- Returns:
- A new Query instance.
-
isClosed
public boolean isClosed()Gets if Session instance has been closed or not.- Returns:
- TRUE if the Session instance has been closed, FALSE otherwise.
- See Also:
-
commit
public void commit()Commits a transaction. -
getGraph
-
close
public void close()Closes the Session instance.It must be called to ensure the integrity of all data.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
newObjects
-
getInMemoryPoolCapacity
public long getInMemoryPoolCapacity()Gets the capacity of the in-memory pool.- Returns:
- Returns the capacity of the in-memory pool
-