Java Code Examples for org.neo4j.driver.SessionConfig#Builder
The following examples show how to use
org.neo4j.driver.SessionConfig#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Neo4JGraph.java From neo4j-gremlin-bolt with Apache License 2.0 | 6 votes |
Neo4JSession currentSession() { // get current session Neo4JSession session = this.session.get(); if (session == null) { // session config SessionConfig.Builder config = SessionConfig.builder() .withDefaultAccessMode(readonly ? AccessMode.READ : AccessMode.WRITE) .withBookmarks(bookmarks); // set database if needed if (database != null) config.withDatabase(database); // create new session session = new Neo4JSession(this, driver.session(config.build()), vertexIdProvider, edgeIdProvider, readonly); // attach it to current thread this.session.set(session); } return session; }
Example 2
Source File: Neo4jTransactionUtils.java From sdn-rx with Apache License 2.0 | 5 votes |
public static SessionConfig sessionConfig(boolean readOnly, Collection<Bookmark> bookmarks, @Nullable String databaseName) { SessionConfig.Builder builder = SessionConfig.builder() .withDefaultAccessMode(readOnly ? AccessMode.READ : AccessMode.WRITE) .withBookmarks(bookmarks); if (databaseName != null) { builder.withDatabase(databaseName); } return builder.build(); }
Example 3
Source File: Neo4JTestGraphProvider.java From neo4j-gremlin-bolt with Apache License 2.0 | 5 votes |
@Override public void clear(Graph graph, Configuration configuration) throws Exception { // check graph instance if (graph != null) { // close graph instance graph.close(); } // create driver instance Driver driver = Neo4JGraphFactory.createDriverInstance(configuration); // session configuration SessionConfig.Builder config = SessionConfig.builder(); // check database is set String database = configuration.getString(Neo4JGraphConfigurationBuilder.Neo4JDatabaseConfigurationKey, null); if (database != null) { // update session config config.withDatabase(database); } // open session try (Session session = driver.session(config.build())) { // begin transaction try (org.neo4j.driver.Transaction transaction = session.beginTransaction()) { // delete everything in database transaction.run("MATCH (n) DETACH DELETE n"); // commit transaction.commit(); } } }