Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from velo/i93
Fix for i93
- Loading branch information
Showing
4 changed files
with
101 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
driver/src/main/java/org/apache/tinkerpop/gremlin/orientdb/OrientNoTransaction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.apache.tinkerpop.gremlin.orientdb; | ||
|
||
public class OrientNoTransaction extends OrientTransaction { | ||
|
||
public OrientNoTransaction(OrientGraph g) { | ||
super(g); | ||
} | ||
|
||
@Override | ||
public boolean isOpen() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void doOpen() { | ||
// do nothing, no transaction | ||
} | ||
|
||
@Override | ||
protected void doCommit() throws TransactionException { | ||
// do nothing, no transaction | ||
} | ||
|
||
@Override | ||
protected void doRollback() throws TransactionException { | ||
// do nothing, no transaction | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
driver/src/test/java/org/apache/tinkerpop/gremlin/orientdb/TransactionIdsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.apache.tinkerpop.gremlin.orientdb; | ||
|
||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; | ||
import org.apache.tinkerpop.gremlin.structure.Edge; | ||
import org.apache.tinkerpop.gremlin.structure.Vertex; | ||
import org.junit.Test; | ||
|
||
public class TransactionIdsTest { | ||
|
||
@Test | ||
public void withTransaction() { | ||
final String labelVertex = "VertexLabel"; | ||
OrientGraph graph = new OrientGraphFactory("memory:myGraph").getTx(); | ||
Vertex v1 = graph.addVertex(labelVertex); | ||
graph.tx().commit(); | ||
|
||
v1 = graph.traversal().V().next(); | ||
|
||
Vertex v2 = graph.addVertex(labelVertex); | ||
graph.tx().commit(); | ||
|
||
GraphTraversal<Vertex, Edge> traversal = graph.traversal().V(v2.id()).outE().as("edge").otherV().hasId(v2) | ||
.select("edge"); | ||
traversal.hasNext(); | ||
|
||
graph.close(); | ||
} | ||
|
||
@Test | ||
public void withoutTransaction() { | ||
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(); | ||
|
||
graph.close(); | ||
} | ||
|
||
} |