I want to create a relationship in neo4j where a Person has a list of friends. I can do this in two ways using spring-data.
a) Create a class Person with a List repesenting friends and annotate the same with @Relationship.
@NodeEntity(label="Person")
public class Person {
@GraphId
private Long id;
private String firstName;
private String lastName;
private String email;
@Relationship(type = "FRIEND_WITH")
List<Person> friends;
}
b) Create the Person object without any List and create the relationship of "FRIEND_WITH" with Cypher like
@Query "CREATE (a)-[FRIEND_WITH]->(b)"
What are the advantages/disadvanages of both the approaches ?