orientdb-gremlin icon indicating copy to clipboard operation
orientdb-gremlin copied to clipboard

Temporary ID in different transactions

Open To-om opened this issue 5 years ago • 3 comments

When a create a vertex, I get a temporary ID (ends with ":-2"). I can retrieve that vertex with the string representation of the ID only in the same transaction. If I open a new transaction, the ID is unusable

OrientGraph graph1 = factory.getTx();
Vertex v = graph1.addVertex(labelVertex);
String vid = v.id().toString();
Assert.assertEquals(1, graph1.V(vid).toList().size()); // succeeds
graph1.tx().commit();

OrientGraph graph2 = factory.getTx();
Assert.assertEquals(1, graph2.V(vid).toList().size()); // fails

String newId = vid.substring(0, vid.length() - 2) + "0";
Assert.assertEquals(1, graph2.V(vid).toList().size()); // succeeds
graph2.tx().commit();

I suppose replacing ":-2" by ":0" is not the solution. How can I provide a stable ID to client (I am in a web application context) ?

To-om avatar Aug 21 '18 15:08 To-om