2016-08-16 23 views
0

我使用的是this插件,以便我可以使用tinkerpop 3.x与orient DB进行交互。使用OrientDB-Gremlin创建事务

我想知道如何创建不同的交易?

随着TitanDB它的那样简单:

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

我试着用OrientDB-精怪如下:

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

并收到以下错误:

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

这是否意味着获得不同事务的唯一方法是在不同线程的范围内打开它们?

+0

对于任何可能遇到此问题的人,我已经用orient-db gremlin插件提出了这个问题https://github.com/mpollmeier/orientdb-gremlin/issues/87 –

回答

1

它看起来并不仿佛OrientDB实现(我想你正在使用this one)支持螺纹交易(即那些在土卫六与newTransaction()graph.tx().createThreadedTx()的TinkerPop有关模式下创建)。如果您打算在同一事务中运行多个线程,则只需要线程事务。

如果您不需要(在大多数标准用例中您不需要),那么事务只是自动的并绑定到当前线程。换句话说,只要您调用读取或写入图的方法,该线程上的事务就会“打开”,只要您致电graph.tx().commit()graph.tx().rollback(),该线程上的事务就会关闭。

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

是 - 如果你想在同一个线程有两个独立的开放式交易,我想你将不得不开始他们两个单独的线程。

+0

这就是我的想法。谢谢斯蒂芬。 –