@NodeEntity
public class Entity {
...
}
@RelationshipEntity
public class RelationInstance{
@StartNode
Entity src;
@EndNode
Entity dst;
...
}
Entity en1 = new Entity();
session.save(en1);
Entity en2 = new Entity(); // en2 is not saved.
session.save(new RelationInstance(en1, en2), 0)
I expect that the code throws an exception because en2 is not persisted and we call the second save with a depth parameter of 0. But it seems that it does not throw an exception and saves en2. Why is that? How should I make it throw an exception?
For relationship-centric saves the relationship and the nodes will get persisted.
This is needed because the RelationshipEntity does not get identified just by its own id but also the nodes that the relationship connects.
You are right, the documentation is a little bit vague and should say NodeEntity instead of just entity.