public class GraphTransaction extends Object
int tx=GraphTransaction.begin(graph);
try{
doYourGraphOperations(graph);
doNestedTransaction(graph); // contains calls to begin(), commit(), and maybe rollback()
GraphTransaction.commit(tx);
}catch(ExpectedException re){
// expect exception be thrown
GraphTransaction.rollback(tx);
throw re;
}
If doNestedTransaction() throws an uncaught exception (which means rollback() was not called),
GraphTransaction will handle it properly given the tx parameter.
Supports nested transactions.
When any of the nested transactions calls rollback(),
graph.rollback() actually occurs in the outermost transaction when commit() or rollback() is called.| Modifier and Type | Field and Description |
|---|---|
protected static ThreadLocal<com.tinkerpop.blueprints.TransactionalGraph> |
graphHolder |
protected static ThreadLocal<org.apache.commons.lang.mutable.MutableInt> |
nestingCounter |
protected static ThreadLocal<AtomicBoolean> |
rollbackCalled |
| Constructor and Description |
|---|
GraphTransaction() |
| Modifier and Type | Method and Description |
|---|---|
static int |
begin(com.tinkerpop.blueprints.TransactionalGraph currGraph) |
static void |
checkTransactionsClosed() |
static boolean |
commit(int tx) |
static boolean |
isInTransaction() |
static boolean |
isOuterMostTransaction() |
static boolean |
rollback(int tx)
Assumes commit() will not be called for the corresponding begin() associated with this transaction.
|
protected static final ThreadLocal<com.tinkerpop.blueprints.TransactionalGraph> graphHolder
protected static final ThreadLocal<org.apache.commons.lang.mutable.MutableInt> nestingCounter
protected static final ThreadLocal<AtomicBoolean> rollbackCalled
public static int begin(com.tinkerpop.blueprints.TransactionalGraph currGraph)
public static boolean rollback(int tx)
public static boolean commit(int tx)
public static boolean isInTransaction()
public static boolean isOuterMostTransaction()
public static void checkTransactionsClosed()
Copyright © 2015. All rights reserved.