Interesting question. If I were doing that, my instinct would be to use baseGraph
to start the new transaction, then wrap the created tx
in IdGraph
as follows:
// baseGraph is TitanGraph, g is IdGraph
TransactionalGraph tx = baseGraph.newTransaction();
IdGraph txId = new IdGraph(tx);
Vertex v = txId.addVertex(pageId);
v.setProperty("prop1", prop1);
v.setProperty("prop2", prop2);
v.setProperty("prop3", prop3);
txId.commit();
.....create some edges here using txId
txId.commit();
Wrapping the baseGraph
in IdGraph
only decorates g
with that feature. Since tx
is a "new" graph instance, it too needs to be wrapped as well to get decorated with IdGraph
features. Note that the above code will not work until this issue is resolved:
https://github.com/thinkaurelius/titan/issues/592
I didn't realize that such a wrapping was not possible until this question came up.