public interface Session extends Resource, StatementRunner
Sessions serve two purposes. For one, they are an optimization. By keeping state on the database side, we can avoid re-transmitting certain metadata over and over.
Sessions also serve a role in transaction isolation and ordering semantics. Neo4j requires "sticky sessions", meaning all requests within one session must always go to the same Neo4j instance.
Session objects are not thread safe, if you want to run concurrent operations against the database, simply create multiple sessions objects.
Modifier and Type | Method and Description |
---|---|
Transaction |
beginTransaction()
Begin a new transaction in this session.
|
run, run, run, typeSystem
Transaction beginTransaction()
All data operations in Neo4j are transactional. However, for convenience we provide a StatementRunner.run(String)
method directly on this session interface as well. When you use that method, your statement automatically gets
wrapped in a transaction.
If you want to run multiple statements in the same transaction, you should wrap them in a transaction using this method.
Copyright © 2016. All rights reserved.