Hello,
I have a SpringBoot application where I'm using the following dependency:
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-spring-boot-starter</artifactId>
<version>1.7.5</version>
</dependency>
My application needs to support high level of concurrent access for reads and writes.
At the moment, each time I want to interact with the database I'm creating a new session and then executing multiple transaction on that session scope. In the end, the session is closed. I'm doing it like this:
try (Session session = driver.session()) {
return session.readTransaction(tx -> {
String query = ...
StatementResult result = tx.run(query);
...
});
}
However, I was wondering if this the best way to do it, or if I should avoid the creation of a session everytime an interaction with the database is done. Would not be better to create a session when the application starts reuse that same session over and over? Or have 1 session for reads and another for writes?
I read in the documentation that sessions are not thread-safe. Not even for reads?
Thanks for your help.