Skip to content
okram edited this page Dec 20, 2010 · 21 revisions

A Graph that implements TransactionalGraph is a graph that supports Blueprints-style transactions. A TransactionalGraph has the following methods.

public void setTransactionMode(Mode mode);
public Mode getTransactionMode();
public void startTransaction();
public void stopTransaction(Conclusion conclusion);

Transaction Mode

A TransactionalGraph supports two modes Mode.AUTOMATIC and Mode.MANUAL. In automatic transaction mode, every manipulation to the graph (e.g. set/remove property, add/remove vertex, add/remove edge) is wrapped into a transaction and committed when the respective method completes. In this way, the developer does not need to start and stop transactions as this is automatically handled by the implementation. Upon construction, every TransactionalGraph is in automatic transaction model. In manual transaction mode, the developer is required to manually start and stop transactions when editing the graph.

Manual Transactions

To put a graph in manual transaction model, evaluate the following:

txGraph.setTransactionMode(Mode.MANUAL);

Upon doing so, any edit operation (or group of edit operations) must be wrapped in a transaction. This is done as follows.

txGraph.startTransaction();
// edit operations
tx.stopTransaction(Conclusion.SUCCESS);

There are two types of conclusions: Conclusion.SUCCESS and Conclusion.FAILURE. When a transaction is successful, it is committed to the underlying store. When the transaction is a failure, then all the edit operations up to the start of the transaction are rolled back. Note: Blueprints-enabled graphs do not require transactions for read-based operations.