The reference node is created automatically by neo4, not related to SDN at all.
The only time SDN uses the reference node (automatically) is when you use a type representation strategy that stores they type hierarchy as tree of nodes bound to the reference node.
There is a sample test for connecting nodes to a reference node in SDN, you use a Type to represent the root node and then connect to this entity-type.
in spring-data-neo4j/src/test/java/org/springframework/data/neo4j/repository/GraphRepositoryTest.java
@Test @Transactional
public void testConnectToRootEntity() {
final Node referenceNode = neo4jTemplate.getReferenceNode();
neo4jTemplate.postEntityCreation(referenceNode,RootEntity.class);
final RootEntity root = neo4jTemplate.findOne(referenceNode.getId(), RootEntity.class);
root.setRootName("RootName");
neo4jTemplate.save(root);
assertEquals(referenceNode.getId(), (long) root.getId());
assertEquals("RootName", referenceNode.getProperty("rootName"));
assertEquals("RootName", root.getRootName());
final Person person = new Person();
person.setRoot(root);
neo4jTemplate.save(person);
final Person p2 = neo4jTemplate.findOne(person.getId(), Person.class);
assertEquals(root.getId(),p2.getRoot().getId());
}
@NodeEntity
public class RootEntity {
@GraphId Long id;
String rootName;
public Long getId() {
return id;
}
public String getRootName() {
return rootName;
}
public void setRootName(String rootName) {
this.rootName = rootName;
}
}
Cheers
Michael