Skip to content

Versioning with Neo4j

Asaf Shakarchi edited this page Jun 8, 2014 · 9 revisions

Versioning with Neo4j

Neo4j is a very known graph database implementation and production ready,

Using Antiquity in conjunction with Neo4j is very simple, The only thing required is to initialize a Neo4j blueprints graph instance as the base graph and wrap it with Antiquity's graph implementation,

Creating an embedded Neo4j graph

//Create a neo4j database instance
GraphDatabaseService graph = new GraphDatabaseFactory().newEmbeddedDatabase("target/database/location");
//Wrap it with Blueprints
Neo4j2Graph neo4j2Graph = new Neo4j2Graph(graph);
neo4j2Graph.autoStartTransaction(true);

//Create Antiquity wrapper
Configuration conf = new Configuration.ConfBuilder().build();
TransactionalVersionedGraph<Neo4j2Graph, Long> vg = (TransactionalVersionedGraph) new ActiveVersionedGraph.ActiveVersionedTransactionalGraphBuilder<Neo4j2Graph, Long>(
    neo4j2Graph, new LongGraphIdentifierBehavior()
).init(true).conf(conf).build();

//Do something with vg (versioned graph) here (see other usage examples)