我正在使用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]。为什么会这样?
答案 0 :(得分:3)
这在Neo4j中称为参考节点。这是neo4j的默认行为。它将创建一个节点ID为0且没有属性的节点。