How to retrieve existing session instance?


(D Modi) #1

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()
                .uri("bolt://localhost")
                .credentials("neo4j", "neo4j")
                .build();

        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


(Radke) #2

Hi,

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.