0

I tried to do

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();
    }

since this was allowed in TitanDB before it was acquired by Datastax but I get "Graph does not support transactions"

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)

I couldn't find anything in the documentation other than mentions Datastax DSE Graph as transactional.

Thanks!

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106

1 Answers1

2

Michail, in your other post in which Andy answered, he provided some insight into how DSE "does" transactions at the moment. We do not expose the Tinkerpop transaction API directly to end users. Transactions are currently implicit, each executestatement call will trigger the Tinkerpop transaction mechanisms within DSE Graph Server. Here's a quick and dirty GitHub example showing how transactions work with DSE Graph - https://github.com/jlacefie/GraphTransactionExample

jlacefie
  • 614
  • 3
  • 5
  • for some context: http://stackoverflow.com/a/41232259/986160 @jilacefie Thanks! I also wonder if this accounts for one transaction too (when not done through executeGraph() ): ```Vertex v = g.addV("User").property("uuid","testuuid231").next();``` it seems when I do .next() it actually stores everything till that point so it is a transaction right?.. If I do v.property("someotherprop","testprop") after that it is another transaction? Thanks again and keep the good work :) – Michail Michailidis Dec 20 '16 at 05:50
  • Actually I tried what I say above and it says ```java.lang.IllegalStateException: Property addition is not supported``` when I try to mutate the vertex after it is fetched from the database with .next() – Michail Michailidis Dec 20 '16 at 07:26
  • 1
    Michail, according to the beta doc here: https://github.com/datastax/java-dse-graph/tree/1.0.0-beta1/manual it looks like we don't yet support mutations via the new Fluent API. The string passing mechanism is the way to go for now. I've asked one of our driver team members to review this post as well and correct if necessary. Thank you for the feedback btw. Please feel free to join the datastax academy graph slack room for more direct interactions. – jlacefie Dec 20 '16 at 13:29
  • According to this post I was able to do mutations fine through Gremlin Fluent API (using two approaches): http://stackoverflow.com/questions/41231912/executegraph-is-not-really-needed-in-datastax-dse-5-0-graph-with-java – Michail Michailidis Dec 20 '16 at 16:26