![](/img/trans.png)
[英]executeGraph() is not really needed in Datastax DSE 5.0 Graph with Java?
[英]How to commit and rollback graph operations in Datastax DSE 5.0 Graph?
我试着做
DseCluster dseCluster = null;
try {
dseCluster = DseCluster.builder()
.addContactPoint("192.168.1.43")
.build();
DseSession dseSession = dseCluster.connect();
GraphTraversalSource g = DseGraph.traversal(dseSession, new GraphOptions().setGraphName("graph"));
GraphStatement graphStatement = DseGraph.statementFromTraversal(g.addV("test"));
GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName("graph"));
System.out.println(grs.one().asVertex());
g.tx().commit();
} finally {
if (dseCluster != null) dseCluster.close();
}
因为TitanDB在Datastax收购它之前就允许这样做,但是我得到“ Graph不支持事务”
Exception in thread "main" java.lang.UnsupportedOperationException: Graph does not support transactions
00:27:52.420 [cluster1-nio-worker-0] DEBUG io.netty.buffer.PoolThreadCache - Freed 26 thread-local buffer(s) from thread: cluster1-nio-worker-0
at org.apache.tinkerpop.gremlin.structure.Graph$Exceptions.transactionsNotSupported(Graph.java:1127)
at org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph.tx(EmptyGraph.java:75)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.tx(GraphTraversalSource.java:320)
at testbed.TestBed.main(TestBed.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
除了提到Datastax DSE Graph是事务性的以外,我在文档中什么也找不到。
谢谢!
Michail在Andy回答的另一篇文章中,他提供了有关DSE目前如何进行交易的一些见解。 我们不会直接向最终用户公开Tinkerpop交易API。 事务当前是隐式的,每个executestatement调用将触发DSE Graph Server中的Tinkerpop事务机制。 这是一个快速且肮脏的GitHub示例,显示了事务如何与DSE Graph一起使用-https: //github.com/jlacefie/GraphTransactionExample
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.