I am using Neo4J embedded database with OGM and creating the database service in a directory via the OGM SessionFactory:
Configuration configuration = new Configuration.Builder()
.uris("C:\neoEmbeddedDb")
.build();
factory = new SessionFactory(configuration, packages);
This works well, but now i want to browse the created database with the Neo4J Browser Tool. As i read, i have to expose my database via Bolt to be able to access it.
In the Neo4J Embedded documentation, they use the GraphDatabaseService and simply specify an additional bolt driver to expose the database:
GraphDatabaseService graphDb = new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( DB_PATH )
.setConfig( bolt.type, "BOLT" )
.setConfig( bolt.enabled, "true" )
.setConfig( bolt.address, "localhost:7687" )
.newGraphDatabase();
But unfortunately, i don't have this option when using the OGM SessionFactory. I tried to call the Configuration Builder with multiple URIs:
Configuration configuration = new Configuration.Builder()
.uris(new String[]{this.databasePath.toUri().toString(), "localhost:7687"})
.build();
But it seems to ignore the first URI (my file location) and instead creates the database in a temporary location.
The debug output logs a corresponding message to the console:
Creating temporary file store: file:/C:/Temp/neo4jTmpEmbedded.db2736315981519762299/database/
Can anyone explain how i can expose my embedded database via bolt or access it otherwise with the Neo4J Browser?
Many thanks!
Solution
With meistermeier's help i was able to create a real EmbeddedDatabase and connect my OGM to it. I added the Bolt connection options as i found them in the documentation. Now, the database is created and properly exposed via Bolt. I can connect with my Neo4J Desktop Windows Browser.
The final code is
BoltConnector boltConnector = new BoltConnector(_BOLT_CONNECTION_STRING);
GraphDatabaseService graphDb = new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder(databasePath.toFile())
.setConfig(boltConnector.type, "BOLT" )
.setConfig(boltConnector.enabled, "true" )
.setConfig(boltConnector.listen_address, "localhost:7687" )
.setConfig(GraphDatabaseSettings.auth_enabled, "false")
.newGraphDatabase();
registerShutdownHook(graphDb);
// connect OGM session factory to embedded database
EmbeddedDriver driver = new EmbeddedDriver(graphDb);
final String[] packages = new String[] {
"Entity domain package",
};
factory = new SessionFactory(driver, packages);