No description or website provided.
Latest commit cc2f1d6 Jun 15, 2011 @dmontag Updated README


Neo4j Versioning

Implements time machine style versioning. Every change to the graph bumps the version number used. The graph can then be viewed at any given version number. With fairly little effort, this library can be modified to provide timestamp-based versioning instead.

Implementation-wise, it stores a validity range on relationships, and also keeps versioned copies of node properties. Indices and relationship properties are currently not versioned.

To set up

Add a VersioningTransactionEventHandler as a transaction event handler to the GraphDatabaseService used:

GraphDatabaseService graphDb = ...;
VersioningTransactionEventHandler eventHandler = new VersioningTransactionEventHandler(graphDb.getReferenceNode());

The event handler takes a constructor argument which is a node to store the config on, so that the latest version
number can be stored in-graph.

To read

Use a VersionContext to browse the graph as it looked at a given version.

import static;

// Obtain node from somewhere, e.g. index lookups
Node someNode = ...;

// Versioned node, seeing the graph as it looked at time 1234
Node versionedNode = vc(1234).node(someNode);

long snapshot = eventHandler.getLatestVersion();
Node head = vc(snapshot).node(someNode);

To write

Most things are taken care of by the event handler seamlessly. Every transaction will bump the version number.

Transaction tx = graphDb.beginTx();
try {
    Node bob = graphDb.createNode();
    Node jim = graphDb.createNode();
    bob.createRelationshipTo(jim, KNOWS);
} finally {

Deletion of nodes and relationships must be done specially.

Transaction tx = graphDb.beginTx();
try {
} finally {


This versioning component does currently not cover indexing.