在Transaction内部创建Edge的例外情况

时间:2014-11-27 15:04:40

标签: orientdb

我对orientDB很新,所以我可能做了一些非常错误的事情,仍然在这里:

OrientGraphFactory factory = new OrientGraphFactory("remote:localhost/testdb","root","12345").setupPool(2, 10);;

我创建了一些VertexTypes和EdgeTypes:

OrientGraphNoTx graph = factory.getNoTx();
graph.createVertexType("Company");
graph.createVertexType("Contract");
graph.createEdgeType("SignedWith");

还创建了一些索引:

graph.createKeyIndex("itemid", Vertex.class, new Parameter<>("class", "Contract" ));
graph.createKeyIndex("itemid", Vertex.class, new Parameter<>("class", "Company"));

现在在创建时我会执行以下操作:

OrientGraph graph = factory.getTx();

Vertex contract = graph.addVertex("class:Contract");
contract.setProperty("itemid", field.longValue());
[... many other properties]

Vertex company = graph.addVertex("class:Company");
company.setProperty("itemid", field.longValue());
[... many other properties]

contract.addEdge("SignedWith", company);
// Also tried this way:
//graph.addEdge(null, contract, company ,"SignedWith" );

每次我一直得到:

[debug] c.j.n.n.OrientDBUtils - verify contract has id : #16:-2
[debug] c.j.n.n.OrientDBUtils - verify company has id : #12:-2
[error] c.j.n.c.OrientDBIndexerRunnable - NeoIndexerRunnable - indexing problem Contract Id:20
com.orientechnologies.orient.core.exception.ORecordNotFoundException: The record with id '#16:-2' not found
 at com.orientechnologies.orient.core.record.ORecordAbstract.reload(ORecordAbstract.java:320) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.impl.ODocument.reload(ODocument.java:653) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.impl.ODocument.reload(ODocument.java:69) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.ORecordAbstract.checkForLoading(ORecordAbstract.java:470) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.impl.ODocument.rawField(ODocument.java:819) ~[orientdb-core-2.0-M3.jar:2.0-M3]
Caused by: com.orientechnologies.orient.core.exception.ORecordNotFoundException: Record with rid #16:-2 was not found in database
 at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.reload(ODatabaseDocumentTx.java:1389) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.reload(ODatabaseDocumentTx.java:123) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.ORecordAbstract.reload(ORecordAbstract.java:314) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.impl.ODocument.reload(ODocument.java:653) ~[orientdb-core-2.0-M3.jar:2.0-M3]
 at com.orientechnologies.orient.core.record.impl.ODocument.reload(ODocument.java:69) ~[orientdb-core-2.0-M3.jar:2.0-M3]

我错过了什么吗?

在Linux上运行orientDB 2.0-M3。

非常感谢你的帮助

1 个答案:

答案 0 :(得分:0)

当事务在创建Vertexes之间回滚时会发生这种情况。

当一个事务不可用或被回滚时,我期望在使用OrientGraph对象创建Vertex时看到更明确的异常。它实际上会自动创建一个新的交易。