我正在尝试使用 Neo4j Java api 的以下简单示例:
public void createDB(String datasetRoot) {
GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("data/Neo4jTest1");
registerShutdownHook(graphDb);
Transaction tx = graphDb.beginTx();
try {
// Database operations go here
Node firstNode = graphDb.createNode();
firstNode.setProperty("nodeId", "1");
Node secondNode = graphDb.createNode();
secondNode.setProperty("nodeId", "2");
Relationship relationship = firstNode.createRelationshipTo(secondNode, RelTypes.SIMILAR);
tx.success();
}
finally {
tx.finish();
}
当我尝试打印所有创建的节点时,我注意到生成了没有属性的 Node[0]。为什么会这样?