orientdb-gremlin
orientdb-gremlin copied to clipboard
How Transactions Affect IDs
Hello Again,
I have another problem. The following code fails:
final String labelVertex = "VertexLabel";
OrientGraph graph = new OrientGraphFactory("memory:myGraph").getNoTx();
Vertex v1 = graph.addVertex(labelVertex);
graph.tx().commit();
v1 = graph.traversal().V().next();
Vertex v2 = graph.addVertex(labelVertex);
GraphTraversal<Vertex, Edge> traversal =graph.traversal().V(v2.id()).outE().as("edge").otherV().hasId(v2).select("edge");
traversal.hasNext();
but if I change graph.tx().commit(); to graph.commit(); it works.
The reason appears to be that the former approach results in v2 having a temporary negative id of -2, while the latter approach appears to result in a normal id.
The negative id results in the traversal failing. Is this intentional ? Can someone explain why the one approach assigns temporary negative ids after commit while the other approach doesn't ?
I have the same issue: I get IDs with :-2. The gremlin step "hasId" fails with these IDs:
INFO: $ANSI{green {db=test-0.32134751615175705}} Error during db request
com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error parsing query:
SELECT FROM `V_MyClass` WHERE `~id` = :~id
^
Encountered "" at line 1, column 35.
Was expecting one of:
DB name="test-0.32134751615175705"
Error Code="1"
at com.orientechnologies.orient.core.sql.parser.OStatementCache.throwParsingException(OStatementCache.java:140)
at com.orientechnologies.orient.core.sql.parser.OStatementCache.parse(OStatementCache.java:132)
at com.orientechnologies.orient.core.sql.parser.OStatementCache.get(OStatementCache.java:81)
at com.orientechnologies.orient.core.sql.parser.OStatementCache.get(OStatementCache.java:63)
at com.orientechnologies.orient.core.sql.OSQLEngine.parse(OSQLEngine.java:71)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.command(ODatabaseDocumentEmbedded.java:563)
at org.apache.tinkerpop.gremlin.orientdb.OrientGraph.lambda$querySql$4(OrientGraph.java:271)
at org.apache.tinkerpop.gremlin.orientdb.OrientGraph.executeWithConnectionCheck(OrientGraph.java:193)
...
Actually, my hasId problem is not related to this issue. HasId step fails with any string representation of ID.
Hi @To-om
yes it is different. I see a problem on the generated query. Let me fix it
Thanks
Hi @To-om
how can i reproduce this?
I've created a dedicated issue (#150) with unit tests (#149)