Neo4J SpringData relationship mapping.
It is not clear to me the meaning (and the effect) of specifying BOTH type relationships.
If I have a User class with a 1:1 relationship with a UserProfile class, should i specify:
@RelatedTo(type = "USER_PROFILE", direction = Direction.BOTH, elementClass = UserProfile.class)
protected UserProfile profile;
and, in the UserProfile class, a
@RelatedTo(type = "USER_PROFILE", direction = Direction.BOTH, elementClass = User.class)
private User user;
or could be better to have
@RelatedTo(type = "USER_PROFILE", direction = Direction.OUTGOING, elementClass = UserProfile.class)
protected UserProfile profile;
and, in the UserProfile class, a
@RelatedTo(type = "USER_PROFILE", direction = Direction.INCOMING, elementClass = User.class)
private User user;
1) In the Neo4J Graph DB, would there be a couple of directed edges between one user instance and one profile instance or a single edge?
2) What is the main difference between the two solutions?
Actually, it is not clear to me the meaning of this text from Hunger's GOOD RELATIONSHIPS book:
"By setting direction to BOTH, relationships are created in the outgoing direction, but when the 1:N field
is read, it will include relationships in both directions. A cardinality of M:N is not necessary because
relationships can be navigated in both directions."