2016-08-16 26 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

這就是我的想法。謝謝斯蒂芬。 –