I am trying to return a Vertex (in tinkerpop format) that it was just created with Gremlin:
DseCluster dseCluster = DseCluster.builder()
.addContactPoint(DbC.dseHost)
.build();
DseSession dseSession = dseCluster.connect();
GraphTraversal traversal = graph.addV(VertexLabels.User)
.property("username", "testuser")
GraphStatement graphStatement = DseGraph.statementFromTraversal(
traversal
);
GraphResultSet grs = dseSession.executeGraph(graphStatement.setGraphName(DbC.graphName));
Vertex v = grs.one().as(Vertex.class);
and I am getting this exception...
java.lang.ClassCastException: com.datastax.driver.dse.graph.DefaultVertex cannot be cast to org.apache.tinkerpop.gremlin.structure.Vertex
How could the code be changed so that it returns in gremlin.structure.Vertex format instead of the DSE Graph Vertex format?
I am using:
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>dse-driver</artifactId>
<version>1.1.1-beta1</version>
</dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>java-dse-graph</artifactId>
<version>1.0.0-beta1</version>
</dependency>
I hope this can be done otherwise migration from TitanDB will be painful..
According to the lengthy discussion I had with Datastax Team through jira and emails:
It is indeed possible to have Fluent API and get back pure Gremlin/tinkerpop objects. This is possible as illustrated here (java-dse graph 1.x documentation) using next(), toList() directly on GraphTraversalSource and not using executeGraph() which will return the DSE Objects.
So the above code changes to:
where
graph
is aGraphTraversalSource<Vertex,Vertex>
object andVertex
is aorg.apache.tinkerpop.gremlin.structure.Vertex
object.