使用 OrientDB-Gremlin 创建事务

Creating Transactions With OrientDB-Gremlin

我正在使用 this 插件,这样我就可以使用 tinkerpop 3.x 与 orient DB 交互。

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

使用 TitanDB 就这么简单:

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

我用 OrientDB-Gremlin 尝试了以下操作:

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

并收到以下错误:

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

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

看起来 OrientDB 实现(我想你正在使用 this one)似乎不支持线程事务(即在 Titan 中使用 newTransaction() 或在 graph.tx().createThreadedTx()).如果您打算让多个线程对同一事务进行操作,则只需要线程事务。

如果您不需要它(在大多数标准用例中您不需要),那么事务只是自动的并绑定到当前线程。换句话说,一旦调用读取或写入图形的方法,该线程上的事务就是 "opened",一旦调用 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 ?

是的 - 如果您希望同一个线程有两个单独的打开事务,我想您必须在两个单独的线程中启动它们。