Showing results for 
Search instead for 
Did you mean: 

How to retrieve existing session instance?


Hi All,

I am trying to use session from Spring Data Neo4j framework. I have the following session initiation method right now, but it is only a work around.

        Configuration configuration = new Configuration.Builder()
                .credentials("neo4j", "neo4j")

        SessionFactory sessionFactory = new SessionFactory(configuration, "com.pkg.domain");
        session = sessionFactory.openSession();

Now, I want to find a way to retrieve the existing session created by the Spring Boot Application with Neo4j using the config from my application properties. Creating a new session for a request everytime is not the best solution for me, so please suggest if you know a way to retrieve the existing session object. I tried to use the Neo4jSessionFactory class, but it doesn't work for my OGM version. I am using OGM 3.1.1


Node Clone


what are you trying to do with the session? When working with with spring-data-neo4j, you hardly need the underlying session.
Perhaps folks here can suggest better ways to archive what you try to do.

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.