Search code examples
orientdbgremlintinkerpop3

Creating Transactions With OrientDB-Gremlin


I am using this plugin so that I can interface with orient DB using tinkerpop 3.x .

I am wondering how can I create different transactions ?

With TitanDB its as simple as:

t1 = graph.newTransaction();
t2 = graph.newTransaction();
t3 = graph.newTransaction();

I tried the following with OrientDB-Gremlin:

t1 = graph.tx().createThreadedTx();
t2 = graph.tx().createThreadedTx();

and received the following error:

java.lang.UnsupportedOperationException: Graph does not support threaded transactions

Does this mean the only way to get different transactions is to open them within the scope of a different thread ?


Solution

  • It doesn't look as though the OrientDB implementation (I suppose you are using this one) supports threaded transactions (i.e. those created in Titan with newTransaction() or under the TinkerPop model of graph.tx().createThreadedTx()). You only need threaded transactions if you intend to have more than one thread operating on the same transaction.

    If you do not need that (in most standard use cases you don't), then transactions are simply automatic and bound to the current thread. In other words, as soon as you call a method that reads or writes to the graph, the transaction on that thread is "opened" and as soon as you call graph.tx().commit() or graph.tx().rollback() the transaction on that thread is closed.

    Does this mean the only way to get different transactions is to open them within the scope of a different thread ?

    Yes - if you wanted the same thread to have two separate open transactions, I guess you would have to start them in two separate threads.