@Node
public class User {
@Id
@GeneratedValue(generatorClass = UUIDStringGenerator.class)
private String id;
private String username;
}
@RelationshipProperties
public class Member {
@RelationshipId
private Long id;
@TargetNode
private User user;
private String type;
}
@Node
public class BusinessUnit {
@Id
@GeneratedValue(generatorClass = UUIDStringGenerator.class)
private String id;
private String name;
@Relationship
private List<Member> members;
}
@Transactional
public void addMember(String name) {
User user = userRepository.save(User.builder()
.username(name)
.build());
BusinessUnit bu = businessUnitRepository.findByName("xxx");
bu.getMembers().add(Member.builder()
.type("gold")
.user(user)
.build());
businessUnitRepository.save(bu);
}
Adding one Member works.
But adding a second one does not create the relationship
What am I doing wrong?